testutils

package
v0.0.0-...-0e769ad Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: AGPL-3.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestClient

func CreateTestClient(t testing.TB, url string) *httpexpect.Expect

CreateTestClient setup an httpexpect.Expect client used to make http tests.

This init take allow to use the `--debug` flag in your tests in order to print the requests/responses content.

example: `go test ./web/permissions --debug`.

func DisableManager

func DisableManager(inst *instance.Instance, shouldRemoveUUID bool) error

func EICARTestSignature

func EICARTestSignature() []byte

EICARTestSignature returns the EICAR test file content. This is a standard test file that all antivirus software should detect. It is NOT a real virus, just a test signature. See: https://www.eicar.org/download-anti-malware-testfile/

func NeedCouchdb

func NeedCouchdb(t *testing.T)

NeedCouchdb kill the process if there is no couchdb running

func TODO

func TODO(t *testing.T, date string, args ...interface{})

TODO can be used as a reminder to do something in the future. The test that calls TODO will fail after the limit date, which is an efficient way to not forget about it.

func WaitForOrFail

func WaitForOrFail(t testing.TB, timeout time.Duration, condition func() bool)

func WithFlag

func WithFlag(t *testing.T, inst *instance.Instance, name string, value interface{})

func WithManager

func WithManager(t *testing.T, inst *instance.Instance, managerConfig ManagerConfig) (shouldRemoveUUID bool)

Types

type ClamAVFixture

type ClamAVFixture struct {
	Container tc.Container
	Address   string // e.g. "127.0.0.1:3310" for clamd TCP connection
	Host      string
	Port      string
	// contains filtered or unexported fields
}

ClamAVFixture holds the ClamAV test container and connection information.

func StartClamAV

func StartClamAV(t *testing.T) *ClamAVFixture

StartClamAV starts a ClamAV container with clamd daemon exposed on a random port. The container uses the official clamav/clamav image. Note: The first startup may take 1-2 minutes as ClamAV downloads virus definitions.

func (*ClamAVFixture) Restart

func (f *ClamAVFixture) Restart(ctx context.Context, timeout time.Duration)

Restart restarts the ClamAV container.

func (*ClamAVFixture) Stop

func (f *ClamAVFixture) Stop(ctx context.Context, timeout time.Duration)

Stop stops the ClamAV container.

type ManagerConfig

type ManagerConfig struct {
	URL              string
	WithPremiumLinks bool
}

type RabbitFixture

type RabbitFixture struct {
	Container   tc.Container
	AMQPURL     string // e.g. amqp://user:pass@127.0.0.1:randomPort/
	AMQPSURL    string // e.g. amqps://user:pass@127.0.0.1:randomPort/
	ManageURL   string // e.g. http://user:pass@127.0.0.1:randomPort/
	Username    string
	Password    string
	MappedAMQP  string
	MappedAMQPS string
	MappedHTTP  string
	// contains filtered or unexported fields
}

func StartRabbitMQ

func StartRabbitMQ(t *testing.T, withVolume bool, enableTLS bool) *RabbitFixture

StartRabbitMQ starts up a RabbitMQ container with random host ports

func (*RabbitFixture) Restart

func (f *RabbitFixture) Restart(ctx context.Context, timeout time.Duration)

func (*RabbitFixture) Stop

func (f *RabbitFixture) Stop(ctx context.Context, timeout time.Duration)

type TestSetup

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

TestSetup is a wrapper around a testing.M which handles setting up instance, client, VFSContext, testserver and cleaning up after itself

func NewSetup

func NewSetup(t testing.TB, name string) *TestSetup

NewSetup returns a new TestSetup name is used to prevent bug when tests are run in parallel

func (*TestSetup) GetTestAdminClient

func (c *TestSetup) GetTestAdminClient() (*oauth.Client, string)

GetTestAdminClient creates an oauth client and associated token with access to admin routes

func (*TestSetup) GetTestClient

func (c *TestSetup) GetTestClient(scopes string) (*oauth.Client, string)

GetTestClient creates an oauth client and associated token

func (*TestSetup) GetTestInstance

func (c *TestSetup) GetTestInstance(opts ...*lifecycle.Options) *instance.Instance

GetTestInstance creates an instance with a random host The instance will be removed on container cleanup

func (*TestSetup) GetTestServer

func (c *TestSetup) GetTestServer(prefix string, routes func(*echo.Group),
	mws ...func(*echo.Echo) *echo.Echo) *httptest.Server

GetTestServer start a testServer with a single group on prefix The server will be closed on container cleanup

func (*TestSetup) GetTestServerMultipleRoutes

func (c *TestSetup) GetTestServerMultipleRoutes(mpr map[string]func(*echo.Group), mws ...func(*echo.Echo) *echo.Echo) *httptest.Server

GetTestServerMultipleRoutes starts a testServer and creates a group for each pair of (prefix, routes) given. The server will be closed on container cleanup.

func (*TestSetup) InstallMiniApp

func (c *TestSetup) InstallMiniApp() (string, error)

func (*TestSetup) InstallMiniClientSideKonnector

func (c *TestSetup) InstallMiniClientSideKonnector() (string, error)

func (*TestSetup) InstallMiniKonnector

func (c *TestSetup) InstallMiniKonnector() (string, error)

func (*TestSetup) SetupSwiftTest

func (c *TestSetup) SetupSwiftTest()

SetupSwiftTest can be used to start an in-memory Swift server for tests.

Jump to

Keyboard shortcuts

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