testing

package
v0.6.10-0...-926069d Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DynamoAccessKeyID     = dev.DynamoAccessKeyID
	DynamoSecretAccessKey = dev.DynamoSecretAccessKey
	DynamoDBHost          = dev.DynamoDBHost
)

DynamoDB

View Source
const (
	RabbitMQHost      = dev.RabbitMQHost
	RabbitMQQueueName = "chord-paper-tracks-test"
)

RabbitMQ

View Source
const (
	SongsTable      = "Songs"
	UsersTable      = "Users"
	TrackListsTable = "TrackLists"
)
View Source
const (
	ServerPort = ":5010"
)

Server

Variables

View Source
var (
	// in the system, is Google validated, and owner of songs and tracklists
	PrimaryUser = User{
		ID:    "primary-user-id",
		Name:  "Primary User Name",
		Email: "[email protected]",
	}

	// in the system, is Google validated, but not owner of songs and tracklists
	OtherUser = User{
		ID:    "other-user-id",
		Name:  "Other User Name",
		Email: "[email protected]",
	}

	// is Google validated but not in the system
	NoAccountUser = User{
		ID:    "not-in-db-id",
		Name:  "Not In DB User",
		Email: "[email protected]",
	}

	// not Google validated, also not in the system
	GoogleUnauthorizedUser = User{
		ID:    "google-unauthorized-user-id",
		Name:  "Google Unauthorized User",
		Email: "[email protected]",
	}
)

Functions

func AfterSuiteDB

func AfterSuiteDB(db dynamolib.DynamoDBWrapper)

func AfterSuiteRabbitMQ

func AfterSuiteRabbitMQ(conn *amqp091.Connection)

func BeforeSuiteDB

func BeforeSuiteDB(testRegion string) dynamolib.DynamoDBWrapper

func CreateAllTables

func CreateAllTables(db dynamolib.DynamoDBWrapper)

func DecodeJSON

func DecodeJSON[T any](jsonBody io.Reader) T

func DecodeJSONError

func DecodeJSONError(jsonBody io.Reader) api_error.JSONAPIError

func DeleteAllTables

func DeleteAllTables(db dynamolib.DynamoDBWrapper)

func DynamoConfig

func DynamoConfig(region string) config.LocalDynamo

func EnsureUser

func EnsureUser(db dynamolib.DynamoDBWrapper, u User)

func EnsureUsers

func EnsureUsers(db dynamolib.DynamoDBWrapper)

func ExpectJSONEqualExceptLastSavedAt

func ExpectJSONEqualExceptLastSavedAt(a map[string]any, b map[string]any)

compare most of the fields, except last saved at

func ExpectSuccess

func ExpectSuccess[T any](t T, err error) T

func ExpectType

func ExpectType[T any](thing any) T

func LoadDemoSong

func LoadDemoSong() map[string]any

func MakeRabbitMQConnection

func MakeRabbitMQConnection() *amqp091.Connection

func MakeRabbitMQPublisher

func MakeRabbitMQPublisher(conn *amqp091.Connection) *rabbitmq.QueuePublisher

func MakeTestDB

func MakeTestDB(testRegion string) dynamolib.DynamoDBWrapper

func PrepareEchoContext

func PrepareEchoContext(request *http.Request, response http.ResponseWriter) echo.Context

func ResetDB

func ResetDB(db dynamolib.DynamoDBWrapper)

func ResetRabbitMQ

func ResetRabbitMQ(conn *amqp091.Connection)

func ServerConfig

func ServerConfig(dbRegion string) server_app.Config

func ServerEndpoint

func ServerEndpoint(path string) string

func SetTestEnv

func SetTestEnv()

func TokenForUserID

func TokenForUserID(userID string) string

func WorkerConfig

func WorkerConfig(dbRegion string, cloudStorageConfig config.LocalCloudStorage) worker_app.Config

Types

type RabbitMQConsumer

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

func NewRabbitMQConsumer

func NewRabbitMQConsumer(conn *amqp091.Connection) RabbitMQConsumer

func (*RabbitMQConsumer) AsyncStart

func (r *RabbitMQConsumer) AsyncStart()

func (*RabbitMQConsumer) Stop

func (r *RabbitMQConsumer) Stop()

func (*RabbitMQConsumer) Unload

func (r *RabbitMQConsumer) Unload() ([]ReceivedMessage, error)

type ReceivedMessage

type ReceivedMessage struct {
	Type    string
	Message map[string]any
}

type RequestFactory

type RequestFactory struct {
	Method  string
	Target  string
	JSONObj any
	Mods    RequestModifiers
}

func (RequestFactory) Do

func (r RequestFactory) Do() (*http.Response, error)

func (RequestFactory) MakeFake

func (r RequestFactory) MakeFake() *http.Request

type RequestModifier

type RequestModifier func(r *http.Request)

func WithAuthHeader

func WithAuthHeader(header string) RequestModifier

func WithUserCred

func WithUserCred(user User) RequestModifier

type RequestModifiers

type RequestModifiers []RequestModifier

func (*RequestModifiers) Add

func (r *RequestModifiers) Add(mods ...RequestModifier)

type User

type User struct {
	ID    string `dynamo:"id,hash"`
	Name  string `dynamo:"username"`
	Email string `dynamo:"email"`
}

type Validator

type Validator struct{}

func (Validator) ValidateToken

func (t Validator) ValidateToken(ctx context.Context, requestToken string) (google_id.User, error)

Jump to

Keyboard shortcuts

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