mock

package
v0.0.0-...-8ba40cc Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestPassword = "test"

	// Encoded hash for "test". Created with `./hashpass test`
	TestPasswordHash = "" /* 140-byte string literal not displayed */
)

Variables

View Source
var (
	ArticleValid = app.Article{
		Id:          1,
		Title:       "Title",
		Description: "Description",
		Body:        "Body",
		Author:      Author,
		Created:     time.Date(2020, 1, 2, 3, 4, 5, 0, time.UTC),
		Updated:     time.Date(2020, 1, 2, 3, 4, 5, 0, time.UTC),
	}

	ArticleUpdated = app.Article{
		Id:          2,
		Title:       "Other title",
		Description: "Other description",
		Body:        "Other body",
		Author:      Author,
		Created:     time.Date(2019, 1, 2, 3, 4, 5, 0, time.UTC),
		Updated:     time.Date(2019, 1, 2, 3, 4, 5, 0, time.UTC),
	}

	Author = app.Profile{
		Id:   1,
		Name: "author",
		Bio:  "bio",
	}
)
View Source
var (
	Profile1 = app.Profile{
		Id:   1,
		Name: "test",
		Bio:  "test bio",
	}
	Profile2 = app.Profile{
		Id:   2,
		Name: "new",
		Bio:  "new bio",
	}
)
View Source
var (
	UserValid = app.User{
		Id:           1,
		Email:        "test@example.com",
		Name:         "test",
		PasswordHash: TestPasswordHash,
	}

	UserUpdatedUsername = app.User{
		Id:           2,
		Email:        "updated@example.com",
		Name:         "updated",
		PasswordHash: TestPasswordHash,
	}

	UserInvalid = app.User{
		Id:           3,
		Email:        "invalid_hash@example.com",
		Name:         "invalid_hash",
		PasswordHash: "xxx",
	}
)

Functions

This section is empty.

Types

type ArticleStore

type ArticleStore struct {
	ById   map[int]*app.Article
	BySlug map[string]*app.Article
}

ArticleStore is a fake implementation of article.Store as Go map

func NewArticleStore

func NewArticleStore() *ArticleStore

func (*ArticleStore) CreateArticle

func (as *ArticleStore) CreateArticle(a *app.Article) error

func (*ArticleStore) DeleteArticle

func (as *ArticleStore) DeleteArticle(id int) error

func (*ArticleStore) GetArticle

func (as *ArticleStore) GetArticle(slug string) (*app.Article, error)

func (*ArticleStore) ListArticles

func (as *ArticleStore) ListArticles(f *app.ArticleListFilter) ([]*app.Article, error)

func (*ArticleStore) UpdateArticle

func (as *ArticleStore) UpdateArticle(a *app.Article) error

type ProfilesStore

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

ProfilesStore is a fake implementation of profiles.Store as Go map

func NewProfilesStore

func NewProfilesStore() *ProfilesStore

func (*ProfilesStore) GetProfile

func (ps *ProfilesStore) GetProfile(name string, follower *app.Profile) (*app.Profile, error)

type UserStore

type UserStore struct {
	ById    map[int]app.User
	ByEmail map[string]app.User
}

UserStore is a fake implementation of user.Store as Go map

func NewUserStore

func NewUserStore() *UserStore

func (*UserStore) AddUser

func (us *UserStore) AddUser(user *app.User) error

func (*UserStore) GetUser

func (us *UserStore) GetUser(email string) (*app.User, error)

func (*UserStore) GetUserById

func (us *UserStore) GetUserById(id int) (*app.User, error)

func (*UserStore) UpdateUser

func (us *UserStore) UpdateUser(newUser *app.User) error

Jump to

Keyboard shortcuts

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