test

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogDebug

func LogDebug()

LogDebug enables debug log

func ModelTime

func ModelTime(value string) model.Time

ModelTime parses a model.Time panics if not valid

func ModelTimeP

func ModelTimeP(value string) *model.Time

ModelTimeP parses a model.Time panics if not valid

func ModelTimeUTC

func ModelTimeUTC(value string) model.Time

ModelTimeUTC parses a model.Time in utc time. panics if not valid

func Time

func Time(value string) time.Time

Time parses a time panics if not valid

func TimeP

func TimeP(value string) *time.Time

TimeP parses a time panics if not valid

Types

type DashboardWithDatabase

type DashboardWithDatabase struct {
	User      model.User
	Dashboard model.Dashboard

	*gorm.DB
	// contains filtered or unexported fields
}

DashboardWithDatabase wraps gorm.DB and provides helper methods

func (*DashboardWithDatabase) AssertExists

func (d *DashboardWithDatabase) AssertExists(exist bool) *DashboardWithDatabase

AssertExists asserts if the dashboard exists or not.

func (*DashboardWithDatabase) AssertHasEntry

func (d *DashboardWithDatabase) AssertHasEntry(name string, exist bool) *DashboardWithDatabase

AssertHasEntry asserts if the entry exists or not.

func (*DashboardWithDatabase) AssertHasRange

func (d *DashboardWithDatabase) AssertHasRange(name string, exist bool) *DashboardWithDatabase

AssertHasRange asserts if the range exists or not.

func (*DashboardWithDatabase) Entry

Entry adds an entry to the dashboard.

func (*DashboardWithDatabase) Range

Range adds a range to the dashboard.

type Database

type Database struct {
	*gorm.DB
	// contains filtered or unexported fields
}

Database wraps the gorm.DB and provides helper methods

func InMemoryDB

func InMemoryDB(t assert.TestingT) *Database

InMemoryDB create a in memory database for testing.

func (*Database) NewUser

func (d *Database) NewUser(id int, name string, admin bool) model.User

NewUser creates a user

func (*Database) NewUserPass

func (d *Database) NewUserPass(id int, name string, pass []byte, admin bool) model.User

NewUserPass creates a user

func (*Database) User

func (d *Database) User(id int) *UserWithDatabase

User creates a user

type Entry

type Entry struct {
	Level   zerolog.Level
	Message string
}

Entry a test logging entry

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger the test logger with util methods

func NewLogger

func NewLogger(t assert.TestingT) *Logger

NewLogger creates a new test logger

func (*Logger) AssertCount

func (l *Logger) AssertCount(count int)

AssertCount asserts the amount of recorded logging entries

func (*Logger) AssertEntryExists

func (l *Logger) AssertEntryExists(entry Entry)

AssertEntryExists asserts that a logging entry exists

func (*Logger) Dispose

func (l *Logger) Dispose()

Dispose resets the logger

func (*Logger) Run

func (l *Logger) Run(e *zerolog.Event, level zerolog.Level, message string)

Run records log entries

type TimeSpanWithDatabase

type TimeSpanWithDatabase struct {
	User     model.User
	TimeSpan model.TimeSpan

	*gorm.DB
	// contains filtered or unexported fields
}

TimeSpanWithDatabase wraps gorm.DB and provides helper methods

func (*TimeSpanWithDatabase) AssertExists

func (d *TimeSpanWithDatabase) AssertExists(exist bool) *TimeSpanWithDatabase

AssertExists asserts if the tag exists or not.

func (*TimeSpanWithDatabase) AssertHasTag

func (d *TimeSpanWithDatabase) AssertHasTag(key, value string, exist bool) *TimeSpanWithDatabase

AssertHasTag asserts if the tag exists or not.

func (*TimeSpanWithDatabase) AssertHasTagIgnoreValue

func (d *TimeSpanWithDatabase) AssertHasTagIgnoreValue(key string, exist bool) *TimeSpanWithDatabase

AssertHasTagIgnoreValue asserts if the tag exists or not.

func (*TimeSpanWithDatabase) Tag

func (d *TimeSpanWithDatabase) Tag(key string, stringValue string) *TimeSpanWithDatabase

Tag adds a tag to the time span.

type UserWithDatabase

type UserWithDatabase struct {
	User model.User
	*gorm.DB
	// contains filtered or unexported fields
}

UserWithDatabase wraps gorm.DB and provides helper methods

func (*UserWithDatabase) AssertExists

func (d *UserWithDatabase) AssertExists(exist bool) *UserWithDatabase

AssertExists asserts if the tag exists or not.

func (*UserWithDatabase) AssertHasDevice

func (d *UserWithDatabase) AssertHasDevice(name string, exist bool) *UserWithDatabase

AssertHasDevice asserts if a device exists.

func (*UserWithDatabase) AssertHasTagDefinition

func (d *UserWithDatabase) AssertHasTagDefinition(key string, exist bool) *UserWithDatabase

AssertHasTagDefinition asserts if a tag definition exists.

func (*UserWithDatabase) Dashboard

func (d *UserWithDatabase) Dashboard(name string) *DashboardWithDatabase

Dashboard adds a dashboard.

func (*UserWithDatabase) NewDevice

func (d *UserWithDatabase) NewDevice(id int, token string, name string) model.Device

NewDevice creates a device.

func (*UserWithDatabase) NewTagDefinition

func (d *UserWithDatabase) NewTagDefinition(key string) model.TagDefinition

NewTagDefinition creates a tag definition.

func (*UserWithDatabase) RunningTimeSpan

func (d *UserWithDatabase) RunningTimeSpan(from string) *TimeSpanWithDatabase

RunningTimeSpan adds a time span without end.

func (*UserWithDatabase) TimeSpan

func (d *UserWithDatabase) TimeSpan(from string, to string) *TimeSpanWithDatabase

TimeSpan adds a time span.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL