setup

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

test/setup/bufconn_setup.go

Index

Constants

View Source
const BufSize = 1024 * 1024

Variables

This section is empty.

Functions

func CreateTestClientConn

func CreateTestClientConn(t *testing.T, unaryInterceptor grpc.UnaryClientInterceptor, streamInterceptor grpc.StreamClientInterceptor) *grpc.ClientConn

CreateTestClientConn creates a new client connection using bufconn.

func SetupTestDatabase

func SetupTestDatabase(testDBName string) (*sql.DB, error)

SetupTestDatabase initializes the test database.

func TeardownTestDatabase

func TeardownTestDatabase(db *sql.DB, testDBName string) error

TeardownTestDatabase cleans up the test database.

Types

type ServerStruct

type ServerStruct struct {
	AuthServer    *app.AuthServer
	FriendsServer *app.FriendsServer
	ChatServer    *app.ChatServiceServer
}

func InitTestServer

func InitTestServer(t *testing.T, serverConfig TestServerConfig) (*sql.DB, *ServerStruct)

InitTestServer initializes the in-memory gRPC server and the test database.

func InitializeTestResources

func InitializeTestResources(t *testing.T, serverConfig *TestServerConfig, numClients int) ([]*app.RpcClient, *sql.DB, func(), *ServerStruct)

InitializeTestResources initializes the desired number of RpcClients for testing.

type TestFieldHook

type TestFieldHook struct {
	TestName string
}

TestFieldHook is a custom Logrus hook that adds a field to every log entry

func (*TestFieldHook) Fire

func (hook *TestFieldHook) Fire(entry *logrus.Entry) error

Fire adds the test name field to every log entry

func (*TestFieldHook) Levels

func (hook *TestFieldHook) Levels() []logrus.Level

Levels returns the log levels the hook should be applied to

type TestServerConfig

type TestServerConfig struct {
	DbName               string
	Log                  *logrus.Logger
	AccessTokenDuration  time.Duration
	RefreshTokenDuration time.Duration
	TimeProvider         client.TimeProvider
}

func NewDefaultTestServerConfig

func NewDefaultTestServerConfig(t *testing.T) (*TestServerConfig, error)

NewDefaultTestServerConfig creates a TestServerConfig with default values

Jump to

Keyboard shortcuts

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