testutil

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestDBName     = "vulcanito_test"
	TestDBUser     = "vulcanito_test"
	TestDBPassword = "vulcanito_test"
	DBdialect      = "postgres"
)
View Source
const KafkaTestBroker = "localhost:29092"

KafkaTestBroker contains the address of the local broker used for tests.

Variables

View Source
var (
	TestDBconnString = fmt.Sprintf("user=%s password=%s sslmode=disable dbname=%s", TestDBUser, TestDBPassword, TestDBName)
)

Functions

func CreateTestDatabase added in v1.1.4

func CreateTestDatabase(name string) (string, error)

CreateTestDatabase builds an empty database in the default local test server. The name of the DB will be "vulcanito_<name>_test", where <name> corresponds to the name of the function calling this one.

func DBNameForFunc added in v1.1.4

func DBNameForFunc(depth int) string

DBNameForFunc creates the name of a test DB for a function that is calling this one the number of levels above in the calling tree equal to the specified depth. For instance if a function named FuncA calls function, called FuncB that in turn makes the following call: DBNameForFunc(2), this function will return the following name: vulcanito_FuncA_test.

func ErrToStr

func ErrToStr(err error) string

func LoadFixtures

func LoadFixtures(fixturesDir string) error

LoadFixtures ...

func PrepareDatabaseLocal

func PrepareDatabaseLocal(fixturesPath string, f func(pDialect, connectionString string, logger log.Logger, logMode bool, defaults map[string][]string) (api.VulcanitoStore, error)) (api.VulcanitoStore, error)

PrepareDatabaseLocal creates a new local test database for the calling function and populates it the fixtures in the specified path.

func PrepareKafka added in v1.1.4

func PrepareKafka(topics map[string]string) (map[string]string, error)

PrepareKafka creates a new empty topic in the local test Kafka server for each topic name present in topics maps. The name of the topics created will have the following shape: <calling_function_name>_<original_topic_name>_test. It returns a new map with the entities remapped to new topics created.

func SetupDB

func SetupDB(dbDirPath string) error

SetupDB initializes the db to be used in tests.

Types

type AssetTopicData added in v1.2.1

type AssetTopicData struct {
	Payload asyncapi.AssetPayload
	Headers map[string][]byte
}

func ReadAllAssetsTopic added in v1.2.0

func ReadAllAssetsTopic(topic string) ([]AssetTopicData, error)

Jump to

Keyboard shortcuts

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