testing

package
v3.1.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReadStdout func() string

ReadStdout value

View Source
var ResetStdout func()

ResetStdout back to os.Stdout

Functions

func BeforeOnce

func BeforeOnce(beforeBlock func())

BeforeOnce runs the before each block only once

func CreateTestApp added in v0.5.0

func CreateTestApp(db interfaces.DB, options ...map[string]interface{}) *model.App

CreateTestApp with specified optional values

func CreateTestApps added in v0.5.0

func CreateTestApps(db interfaces.DB, n int, options ...map[string]interface{}) []*model.App

CreateTestApps for n apps

func CreateTestJob added in v0.5.0

func CreateTestJob(db interfaces.DB, appID uuid.UUID, templateName string, options ...map[string]interface{}) *model.Job

CreateTestJob with specified optional values

func CreateTestJobs added in v0.5.0

func CreateTestJobs(db interfaces.DB, appID uuid.UUID, templateName string, n int, options ...map[string]interface{}) []*model.Job

CreateTestJobs for n apps

func CreateTestTemplate added in v0.5.0

func CreateTestTemplate(db interfaces.DB, appID uuid.UUID, options ...map[string]interface{}) *model.Template

CreateTestTemplate with specified optional values

func CreateTestTemplates added in v0.5.0

func CreateTestTemplates(db interfaces.DB, appID uuid.UUID, n int, options ...map[string]interface{}) []*model.Template

CreateTestTemplates for n apps

func CreateTestUser

func CreateTestUser(db interfaces.DB, options ...map[string]interface{}) *model.User

CreateTestUser with specified optional values

func CreateTestUsers

func CreateTestUsers(db interfaces.DB, n int, options ...map[string]interface{}) []*model.User

CreateTestUsers for n users

func Delete

func Delete(app *api.Application, url, auth string) (int, string)

Delete from server

func Get

func Get(app *api.Application, url, auth string) (int, string)

Get from server

func GetAppPayload added in v0.5.0

func GetAppPayload(options ...map[string]interface{}) map[string]interface{}

GetAppPayload with specified optional values

func GetConf added in v0.5.0

func GetConf() *viper.Viper

GetConf returns a viper config for the environment we're in

func GetConfPath

func GetConfPath() string

GetConfPath for the environment we're in

func GetDefaultTestApp

func GetDefaultTestApp(logger zap.Logger) *api.Application

GetDefaultTestApp returns a new marathon API Application bound to 0.0.0.0:8833 for test

func GetFaultyTestDB added in v0.5.0

func GetFaultyTestDB(a *api.Application) *pg.DB

GetFaultyTestDB returns an ill-configured database for usage in tests

func GetJobPayload added in v0.5.0

func GetJobPayload(options ...map[string]interface{}) map[string]interface{}

GetJobPayload with specified optional values

func GetTemplatePayload added in v0.5.0

func GetTemplatePayload(options ...map[string]interface{}) map[string]interface{}

GetTemplatePayload with specified optional values

func GetTemplatePayloads

func GetTemplatePayloads(amount int, options ...map[string]interface{}) []map[string]interface{}

GetTemplatePayloads with specified optional values

func GetTestDB

func GetTestDB(a *api.Application) *pg.DB

GetTestDB for usage in tests

func GetUserPayload

func GetUserPayload(options ...map[string]interface{}) map[string]interface{}

GetUserPayload with specified optional values

func MockStdout

func MockStdout()

MockStdout to read it's value later

func Post

func Post(app *api.Application, url, body string, auth string) (int, string)

Post to server

func Put

func Put(app *api.Application, url, body string, auth string) (int, string)

Put to server

func ReadLinesFromIOReader added in v0.5.0

func ReadLinesFromIOReader(reader io.Reader) []string

ReadLinesFromIOReader for testing

func RedisReplyToBytes added in v0.5.0

func RedisReplyToBytes(reply interface{}, err error) ([]byte, error)

RedisReplyToBytes for testing

Types

type FakeKafkaProducer added in v1.0.0

type FakeKafkaProducer struct {
	APNSMessages []string
	GCMMessages  []string
}

FakeKafkaProducer is a mock producer that implements PushProducer interface

func NewFakeKafkaProducer added in v1.0.0

func NewFakeKafkaProducer() *FakeKafkaProducer

NewFakeKafkaProducer creates a new FakeKafkaProducer

func (*FakeKafkaProducer) SendAPNSPush added in v1.0.0

func (f *FakeKafkaProducer) SendAPNSPush(topic, deviceToken string, payload, messageMetadata map[string]interface{}, pushMetadata map[string]interface{}, pushExpiry int64, templateName string) error

SendAPNSPush for testing

func (*FakeKafkaProducer) SendGCMPush added in v1.0.0

func (f *FakeKafkaProducer) SendGCMPush(topic, deviceToken string, payload, messageMetadata map[string]interface{}, pushMetadata map[string]interface{}, pushExpiry int64, templateName string) error

SendGCMPush for testing

type FakeS3 added in v0.5.0

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

FakeS3 for usage in tests

func NewFakeS3 added in v0.5.0

func NewFakeS3(conf *viper.Viper) *FakeS3

NewFakeS3 creates a new FakeS3

func (*FakeS3) CompleteMultipartUpload

func (s *FakeS3) CompleteMultipartUpload(multipartUpload *s3.CreateMultipartUploadOutput, parts []*s3.CompletedPart) error

CompleteMultipartUpload mock the real CompleteMultipartUpload

func (*FakeS3) DownloadChunk

func (s *FakeS3) DownloadChunk(start, size int64, path string) (int, *bytes.Buffer, error)

DownloadChunk get part of the csv file

func (*FakeS3) GetObject added in v0.5.0

func (s *FakeS3) GetObject(path string) ([]byte, error)

GetObject mock the real GetObject

func (*FakeS3) InitMultipartUpload

func (s *FakeS3) InitMultipartUpload(path string) (*s3.CreateMultipartUploadOutput, error)

InitMultipartUpload mock the real InitMultipartUpload

func (*FakeS3) PutObject added in v0.5.0

func (s *FakeS3) PutObject(path string, body *[]byte) (*s3.PutObjectOutput, error)

PutObject mock the real PutObject

func (*FakeS3) PutObjectRequest

func (s *FakeS3) PutObjectRequest(path string) (string, error)

PutObjectRequest mock the real PutObjectRequest

func (*FakeS3) UploadPart

func (s *FakeS3) UploadPart(input *bytes.Buffer, multipartUpload *s3.CreateMultipartUploadOutput,
	partNumber int64) (*s3.UploadPartOutput, error)

UploadPart mock the real UploadPart function

type MyReaderCloser added in v0.5.0

type MyReaderCloser struct {
	io.Reader
}

MyReaderCloser for usage in tests

func (MyReaderCloser) Close added in v0.5.0

func (MyReaderCloser) Close() error

Close for usage in tests

type PGMock added in v1.0.0

type PGMock struct {
	Execs        [][]interface{}
	ExecOnes     [][]interface{}
	Queries      [][]interface{}
	Closed       bool
	RowsAffected int
	RowsReturned int
	Error        error
}

PGMock should be used for tests that need to connect to PG

func NewPGMock added in v1.0.0

func NewPGMock(rowsAffected, rowsReturned int, errOrNil ...error) *PGMock

NewPGMock creates a new instance

func (*PGMock) Begin

func (m *PGMock) Begin() (*pg.Tx, error)

Begin trasaction mock

func (*PGMock) Close added in v1.0.0

func (m *PGMock) Close() error

Close records that it is closed

func (*PGMock) Delete added in v1.0.0

func (m *PGMock) Delete(params interface{}) error

Delete mock for testing

func (*PGMock) Exec added in v1.0.0

func (m *PGMock) Exec(obj interface{}, params ...interface{}) (*types.Result, error)

Exec stores executed params

func (*PGMock) ExecOne added in v1.0.0

func (m *PGMock) ExecOne(obj interface{}, params ...interface{}) (*types.Result, error)

ExecOne stores executed params

func (*PGMock) Insert added in v1.0.0

func (m *PGMock) Insert(params ...interface{}) error

Insert mock for testing

func (*PGMock) Model added in v1.0.0

func (m *PGMock) Model(params ...interface{}) *orm.Query

Model mock for testing

func (*PGMock) Query added in v1.0.0

func (m *PGMock) Query(obj interface{}, query interface{}, params ...interface{}) (*types.Result, error)

Query stores executed params

func (*PGMock) QueryOne

func (m *PGMock) QueryOne(obj interface{}, query interface{}, params ...interface{}) (*types.Result, error)

QueryOne stores executed params

func (*PGMock) Select added in v1.0.0

func (m *PGMock) Select(params interface{}) error

Select mock for testing

func (*PGMock) Update added in v1.0.0

func (m *PGMock) Update(params interface{}) error

Update mock for testing

type TestBuffer

type TestBuffer struct {
	bytes.Buffer
}

TestBuffer is a mock buffer

func (*TestBuffer) Lines

func (b *TestBuffer) Lines() []string

Lines returns all lines of log

func (*TestBuffer) Stripped

func (b *TestBuffer) Stripped() string

Stripped removes new lines

func (*TestBuffer) Sync

func (b *TestBuffer) Sync() error

Sync does nothing

Jump to

Keyboard shortcuts

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