tests

package
v0.0.0-...-b9360c4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GoodPassword = "goodgoodgood"
	BadPassword  = "badbadbadbad"
)

Variables

This section is empty.

Functions

func ExecuteRequest

func ExecuteRequest(req *http.Request, router http.Handler) *httptest.ResponseRecorder

Types

type AddedDataRecords

type AddedDataRecords struct {
	Provision *data.Provision
	Ingestion *data.Ingestion
	Records   []*data.DataRecord
}

type AddedMetaRecords

type AddedMetaRecords struct {
	Provision *data.Provision
	Ingestion *data.Ingestion
	Records   []*data.MetaRecord
}

type FakeProjectStations

type FakeProjectStations struct {
	Owner    *data.User
	Project  *data.Project
	Stations []*data.Station
}

type FilePair

type FilePair struct {
	Meta       []byte
	Data       []byte
	MetaBlocks []uint64
	DataBlocks []uint64
}

type InMemoryArchive

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

func NewInMemoryArchive

func NewInMemoryArchive(files map[string][]byte) (a *InMemoryArchive)

func (*InMemoryArchive) Archive

func (a *InMemoryArchive) Archive(ctx context.Context, contentType string, meta map[string]string, reader io.Reader) (*files.ArchivedFile, error)

func (*InMemoryArchive) DeleteByURL

func (a *InMemoryArchive) DeleteByURL(ctx context.Context, url string) error

func (*InMemoryArchive) Info

func (a *InMemoryArchive) Info(ctx context.Context, key string) (info *files.FileInfo, err error)

func (*InMemoryArchive) OpenByURL

func (a *InMemoryArchive) OpenByURL(ctx context.Context, url string) (of *files.OpenedFile, err error)

func (*InMemoryArchive) Opened

func (a *InMemoryArchive) Opened(ctx context.Context, url string, opened *files.OpenedFile) (*files.OpenedFile, error)

func (*InMemoryArchive) String

func (a *InMemoryArchive) String() string

type MetaAndData

type MetaAndData struct {
	Meta *AddedMetaRecords
	Data *AddedDataRecords
}

type SignedRecordAndData

type SignedRecordAndData struct {
	Signed *pb.SignedRecord
	Data   *pb.DataRecord
	Bytes  []byte
}

type TestConfig

type TestConfig struct {
	PostgresURL string `split_words:"true" default:"postgres://fieldkit:password@127.0.0.1:5432/fieldkit?sslmode=disable" required:"true"`
}

type TestEnv

type TestEnv struct {
	Ctx         context.Context
	DB          *sqlxcache.DB
	DbPool      *pgxpool.Pool
	PostgresURL string
	SessionKey  string
	JWTHMACKey  []byte
	Seed        int64
}

func NewTestEnv

func NewTestEnv() (e *TestEnv, err error)

func (*TestEnv) AddAdminUser

func (e *TestEnv) AddAdminUser() (*data.User, error)

func (*TestEnv) AddIngestion

func (e *TestEnv) AddIngestion(user *data.User, url, typeName string, deviceID []byte, length int) (*data.QueuedIngestion, *data.Ingestion, error)

func (*TestEnv) AddInvalidUser

func (e *TestEnv) AddInvalidUser() (*data.User, error)

func (*TestEnv) AddMetaAndData

func (e *TestEnv) AddMetaAndData(station *data.Station, user *data.User, numberData int) (*MetaAndData, error)

func (*TestEnv) AddProject

func (e *TestEnv) AddProject() (*data.Project, error)

func (*TestEnv) AddProjectActivity

func (e *TestEnv) AddProjectActivity(project *data.Project, station *data.Station, user *data.User) error

func (*TestEnv) AddProjectUser

func (e *TestEnv) AddProjectUser(p *data.Project, u *data.User, r *data.Role) error

func (*TestEnv) AddProjectWithPrivacy

func (e *TestEnv) AddProjectWithPrivacy(privacy data.PrivacyType) (*data.Project, error)

func (*TestEnv) AddProvision

func (e *TestEnv) AddProvision(deviceID, generationID []byte) (*data.Provision, error)

func (*TestEnv) AddRandomSensors

func (e *TestEnv) AddRandomSensors() error

func (*TestEnv) AddStationActivity

func (e *TestEnv) AddStationActivity(station *data.Station, user *data.User) error

func (*TestEnv) AddStations

func (e *TestEnv) AddStations(number int) (*FakeProjectStations, error)

func (*TestEnv) AddStationsOwnedBy

func (e *TestEnv) AddStationsOwnedBy(owner *data.User, number int) ([]*data.Station, error)

func (*TestEnv) AddStationsToProject

func (e *TestEnv) AddStationsToProject(project *data.Project, owner *data.User, number int) (*FakeProjectStations, error)

func (*TestEnv) AddUser

func (e *TestEnv) AddUser() (*data.User, error)

func (*TestEnv) MustDeviceID

func (e *TestEnv) MustDeviceID() []byte

func (*TestEnv) NewAuthorizationHeader

func (e *TestEnv) NewAuthorizationHeader() string

func (*TestEnv) NewAuthorizationHeaderForAdmin

func (e *TestEnv) NewAuthorizationHeaderForAdmin() string

func (*TestEnv) NewAuthorizationHeaderForUser

func (e *TestEnv) NewAuthorizationHeaderForUser(user *data.User) string

func (*TestEnv) NewDataReading

func (e *TestEnv) NewDataReading(meta, reading uint64) *pb.DataRecord

func (*TestEnv) NewFilePair

func (e *TestEnv) NewFilePair(nmeta, ndata int) (*FilePair, error)

func (*TestEnv) NewHttpStatusReply

func (e *TestEnv) NewHttpStatusReply(s *data.Station) *pbapp.HttpReply

func (*TestEnv) NewLiveReadingsReply

func (e *TestEnv) NewLiveReadingsReply(s *data.Station) *pbapp.HttpReply

func (*TestEnv) NewMetaLayout

func (e *TestEnv) NewMetaLayout(record uint64) *SignedRecordAndData

func (*TestEnv) NewRandomData

func (e *TestEnv) NewRandomData(n int) ([]byte, error)

func (*TestEnv) NewStation

func (e *TestEnv) NewStation(owner *data.User) *data.Station

func (*TestEnv) NewTokenForUser

func (e *TestEnv) NewTokenForUser(user *data.User) string

Jump to

Keyboard shortcuts

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