apitest

package
v0.0.0-...-78d125d Latest Latest
Warning

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

Go to latest
Published: Dec 6, 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(t *testing.T, testName string) *Test

New 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