types

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 1 Imported by: 16

Documentation

Overview

Package types contains types to use across the Consumer/Provider tests.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound represents a resource not found (404)
	ErrNotFound = errors.New("not found")

	// ErrUnauthorized represents a Forbidden (403)
	ErrUnauthorized = errors.New("unauthorized")

	// ErrEmpty is returned when input string is empty
	ErrEmpty = errors.New("empty string")
)

Functions

This section is empty.

Types

type LoginRequest

type LoginRequest struct {
	Username string `json:"username" pact:"example=jmarie"`
	Password string `json:"password" pact:"example=issilly"`
}

LoginRequest is the login request API struct.

type LoginResponse

type LoginResponse struct {
	User *User `json:"user"`
}

LoginResponse is the login response API struct.

type User

type User struct {
	Name     string `json:"name" pact:"example=Jean-Marie de La Beaujardière😀😍"`
	Username string `json:"username" pact:"example=jmarie"`
	Password string `json:"password" pact:"example=password123"`
	Type     string `json:"type" pact:"example=admin,regex=^(admin|user|guest)$"`
	ID       int    `json:"id" pact:"example=10"`
}

User is a representation of a User. Dah.

type UserRepository

type UserRepository struct {
	Users map[string]*User
}

UserRepository is an in-memory user database.

func (*UserRepository) ByID added in v1.0.0

func (u *UserRepository) ByID(ID int) (*User, error)

ByID finds a user by their ID

func (*UserRepository) ByUsername

func (u *UserRepository) ByUsername(username string) (*User, error)

ByUsername finds a user by their username.

Jump to

Keyboard shortcuts

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