apitest

package
v0.0.0-...-4a19c39 Latest Latest
Warning

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

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

Documentation

Overview

Package apitest provides support for excuting api test logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Token

func Token(userBus *userbus.Business, ath *auth.Auth, email string) string

Token generates an authenticated token for a user.

Types

type KeyStore

type KeyStore struct{}

KeyStore represents a mock keystore with a hardcoded key.

func (*KeyStore) PrivateKey

func (ks *KeyStore) PrivateKey(kid string) (string, error)

PrivateKey implements the auth interface.

func (*KeyStore) PublicKey

func (ks *KeyStore) PublicKey(kid string) (string, error)

PublicKey implements the auth interface.

type SeedData

type SeedData struct {
	Users  []User
	Admins []User
}

SeedData represents users for api tests.

type Table

type Table struct {
	Name       string
	URL        string
	Token      string
	Method     string
	StatusCode int
	Input      any
	GotResp    any
	ExpResp    any
	CmpFunc    func(got any, exp any) string
}

Table represent fields needed for running an api test.

type Test

type Test struct {
	DB   *dbtest.Database
	Auth *auth.Auth
	// contains filtered or unexported fields
}

Test contains functions for executing an api test.

func New

func New(db *dbtest.Database, ath *auth.Auth, mux http.Handler) *Test

New constructs a Test value for running api tests.

func StartTest

func StartTest(t *testing.T, c *docker.Container, testName string) *Test

StartTest initialized the system to run a test.

func (*Test) Run

func (at *Test) Run(t *testing.T, table []Table, testName string)

Run performs the actual test logic based on the table data.

type User

type User struct {
	userbus.User
	Products []productbus.Product
	Homes    []homebus.Home
	Token    string
}

User extends the dbtest user for api test support.

Jump to

Keyboard shortcuts

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