Documentation ¶
Overview ¶
Package mock supplies various stubs and mock objects that can be used for unit testing and development deployments. nolint
nolint
Index ¶
- Constants
- Variables
- func Diary210101() core.DiaryDay
- func Diary210102() core.DiaryDay
- func Diary210201() core.DiaryDay
- func Diary210202() core.DiaryDay
- func Diary220301() core.DiaryDay
- func Diary220302() core.DiaryDay
- func Diary220312() core.DiaryDay
- func Diary220313() core.DiaryDay
- func Entry1() core.DiaryEntry
- func Entry1New() core.DiaryEntry
- func Entry1Rec1() core.DiaryEntry
- func Entry2() core.DiaryEntry
- func Entry2New() core.DiaryEntry
- func Entry2Rec1() core.DiaryEntry
- func Entry3() core.DiaryEntry
- func Entry3New() core.DiaryEntry
- func Entry4() core.DiaryEntry
- func Entry4New() core.DiaryEntry
- func List1() []core.ShopItem
- func List12() []core.ShopItem
- func Prefs0(user app.User) app.Prefs
- func Recipe0() core.Recipe
- func Recipe1() core.Recipe
- func Recipe2() core.Recipe
- func USDA1() []byte
- type Access
- type DB
- func (db *DB) DelDiaryEntries(id int, entries ...core.DiaryEntry) error
- func (db *DB) DelRecipeInstructions(id int) error
- func (db *DB) DelToken(string) error
- func (db *DB) DelUser(id int) error
- func (db *DB) DiaryDays(id, year, month, day int) ([]core.DiaryDay, error)
- func (db *DB) DiaryEntries(id int, date time.Time) ([]core.DiaryEntry, error)
- func (db *DB) Execute(c app.Command) error
- func (db *DB) Fetch(q app.Query) error
- func (db *DB) Food(id int) (core.Food, error)
- func (db *DB) FoodExists(id int) (bool, error)
- func (db *DB) Foods(f core.Filter) ([]core.Food, error)
- func (db *DB) NewDiaryEntries(id int, entries ...core.DiaryEntry) error
- func (db *DB) NewFood() (int, error)
- func (db *DB) NewRecipe(name string) (int, error)
- func (db *DB) NewToken(id int, hash string, data interface{}) error
- func (db *DB) NewUser(email, hash, token string) (int, error)
- func (db *DB) Recipe(id int) (core.Recipe, error)
- func (db *DB) RecipeAccess(user, rec int) (int, error)
- func (db *DB) RecipeInstructions(id int) (string, error)
- func (db *DB) Recipes(uid int, f core.Filter) ([]core.Recipe, error)
- func (db *DB) SetDiaryEntries(id int, entries ...core.DiaryEntry) error
- func (db *DB) SetFood(food core.Food) error
- func (db *DB) SetRecipe(rec core.Recipe) error
- func (db *DB) SetRecipeAccess(user, rec, perms int) error
- func (db *DB) SetRecipeInstructions(id int, text string) error
- func (db *DB) SetShoppingListDone(id int, done map[int]bool) error
- func (db *DB) SetUser(user app.User) error
- func (db *DB) SetUserPrefs(id int, prefs app.StoredPrefs) error
- func (db *DB) ShoppingList(id int, date ...time.Time) ([]core.ShopItem, error)
- func (db *DB) Token(string) (app.Token, error)
- func (db *DB) UserByEmail(email string) (app.User, error)
- func (db *DB) UserByID(id int) (app.User, error)
- func (db *DB) UserByName(name string) (app.User, error)
- func (db *DB) UserNames(prefix string) ([]string, error)
- func (db *DB) UserPrefs(id int) (app.StoredPrefs, error)
- func (db *DB) WithAccess(a Access) *DB
- func (db *DB) WithDate(date time.Time) *DB
- func (db *DB) WithDays(days ...core.DiaryDay) *DB
- func (db *DB) WithEntries(ents ...core.DiaryEntry) *DB
- func (db *DB) WithError(e ...error) *DB
- func (db *DB) WithFood(food core.Food) *DB
- func (db *DB) WithFoods(foods ...core.Food) *DB
- func (db *DB) WithID(id int) *DB
- func (db *DB) WithInstructions(id int, text string) *DB
- func (db *DB) WithName(name string) *DB
- func (db *DB) WithPrefs(prefs app.StoredPrefs) *DB
- func (db *DB) WithRecipe(rec core.Recipe) *DB
- func (db *DB) WithRecipes(recs ...core.Recipe) *DB
- func (db *DB) WithShoppingList(items ...core.ShopItem) *DB
- func (db *DB) WithToken(tok app.Token) *DB
- func (db *DB) WithUser(user app.User) *DB
- type EmailNotifier
- type Handler
- type Instructions
- type Job
- type Log
- type MarshalFailer
- type Notifier
- type SessionStore
- type Translator
Constants ¶
View Source
const ( Recipe0Json = `` /* 448-byte string literal not displayed */ Recipe1Json = `` /* 561-byte string literal not displayed */ Recipe2Json = `` /* 576-byte string literal not displayed */ )
View Source
const ( Entry1Json = `{"date":"2022-03-12T08:43:00Z","recipe":"","food":{"id":2,"amount":150}}` Entry2Json = `{"date":"2022-03-12T16:43:00Z","recipe":"","food":{"id":1,"amount":50}}` Entry3Json = `{"date":"2022-03-13T08:33:00Z","recipe":"","food":{"id":1,"amount":50}}` )
View Source
const ( Diary210101Json = `` /* 381-byte string literal not displayed */ Diary210102Json = `` /* 381-byte string literal not displayed */ Diary220301Json = `` /* 381-byte string literal not displayed */ Diary220312Json = `` /* 493-byte string literal not displayed */ )
View Source
const (
Instructions1 = "Cook it well."
)
View Source
const (
List1Json = `[{"price":[0,0],"done":false,"amount":50,"aisle":0,"id":1},{"price":[0,0],"done":false,"amount":150,"aisle":0,"id":2}]`
)
Variables ¶
View Source
var ( Date1 = time.Date(2022, 3, 12, 8, 43, 0, 0, time.UTC) Date2 = time.Date(2022, 3, 12, 16, 43, 0, 0, time.UTC) Date3 = time.Date(2022, 3, 13, 8, 33, 0, 0, time.UTC) Date4 = time.Date(2022, 3, 13, 16, 33, 0, 0, time.UTC) Date1p2 = Date1.Add(time.Minute * 2) Date2p2 = Date2.Add(time.Minute * 2) Date1ISO = Date1.Format(time.RFC3339) Date2ISO = Date2.Format(time.RFC3339) Date1Date = Date1.Format("2006-01-02") Date2Date = Date2.Format("2006-01-02") Date3Date = Date3.Format("2006-01-02") Date1Time = Date1.Format("15:04") Date2Time = Date2.Format("15:04") Day1 = Date1.Truncate(time.Hour * 24) Day2 = Date3.Truncate(time.Hour * 24) )
View Source
var ( Food0 = core.Food{ ID: 42, } // apple Food1 = core.Food{ ID: 1, Category: 9, Flags: core.FlagVegan | core.FlagVegetarian, KCal: 54, Fat: 0.1, Carbs: 14.4, Sugar: 10.3, Fructose: 5, Glucose: 3, Sucrose: 2.3, Protein: 0.3, Fiber: 2, Iron: 0.2, Zinc: 0.1, Magnesium: 5, Chlorine: 2.2, Sodium: 1, Calcium: 5.3, Potassium: 119, Phosphorus: 11, Copper: 0.1, Iodine: 0.008, VitA: 0.01, VitB1: 0.04, VitB2: 0.03, VitB6: 0.1, VitC: 12, VitE: 0.49, } // banana Food2 = core.Food{ ID: 2, Category: 9, Flags: core.FlagVegan | core.FlagVegetarian, KCal: 93, Fat: 0.2, Carbs: 20, Sugar: 17, Fructose: 10, Glucose: 4, Sucrose: 3, Protein: 1, Fiber: 2, Iron: 0.4, Zinc: 0.2, Magnesium: 30, Chlorine: 109, Sodium: 1, Calcium: 7, Potassium: 367, Phosphorus: 22, Copper: 0.1, Iodine: 0.003, Manganse: 0.3, VitA: 0.01, VitB1: 0.04, VitB2: 0.06, VitB6: 0.36, VitC: 11, VitE: 0.27, } Food0Json = `` /* 397-byte string literal not displayed */ Food1Json = `` /* 441-byte string literal not displayed */ Food2Json = `` /* 436-byte string literal not displayed */ )
View Source
var ( User1 = app.User{ ID: 1, Email: "a@a.a", Name: "AnnoyingOrange", Pass: "$2a$10$CpVy94BcePvhBH3QS/mMnOtFVrfN0DvwdooEUc0T8tWdKNi3ayFXC", Lang: "en", Perm: app.PermLogin, } User1Pass = "Tr0ub4dor&3" User1Json = `` /* 139-byte string literal not displayed */ User2 = app.User{ ID: 2, Email: "b@b.b", Name: "BadApple", Pass: "$2a$10$CpVy94BcePvhBH3QS/mMnOtFVrfN0DvwdooEUc0T8tWdKNi3ayFXC", Lang: "de", Perm: app.PermAdmin, } )
View Source
var ( Prefs1 = app.Prefs{ Account: app.AccountPrefs{ Email: User1.Email, Name: User1.Name, }, Macros: [7]app.MacroPrefs{ {KCal: 2200, Fat: 60, Carbs: 250, Protein: 165}, {KCal: 2200, Fat: 60, Carbs: 250, Protein: 165}, {KCal: 2600, Fat: 80, Carbs: 285, Protein: 185}, {KCal: 2200, Fat: 60, Carbs: 250, Protein: 165}, {KCal: 2200, Fat: 60, Carbs: 250, Protein: 165}, {KCal: 2200, Fat: 60, Carbs: 250, Protein: 165}, {KCal: 2600, Fat: 80, Carbs: 285, Protein: 185}, }, RDI: app.BaseRDIPrefs(), } StoredPrefs1 = app.StoredPrefs{ Macros: [7]app.MacroPrefs{ {KCal: 2200, Fat: 60, Carbs: 250, Protein: 165}, {KCal: 2200, Fat: 60, Carbs: 250, Protein: 165}, {KCal: 2600, Fat: 80, Carbs: 285, Protein: 185}, {KCal: 2200, Fat: 60, Carbs: 250, Protein: 165}, {KCal: 2200, Fat: 60, Carbs: 250, Protein: 165}, {KCal: 2200, Fat: 60, Carbs: 250, Protein: 165}, {KCal: 2600, Fat: 80, Carbs: 285, Protein: 185}, }, } Prefs1Json = `` /* 804-byte string literal not displayed */ StoredPrefs1Json = `` /* 375-byte string literal not displayed */ StoredPrefs2 = app.StoredPrefs{ Macros: [7]app.MacroPrefs{ {KCal: 2000, Fat: 40, Carbs: 220, Protein: 60}, {KCal: 2100, Fat: 45, Carbs: 230, Protein: 65}, {KCal: 2200, Fat: 50, Carbs: 240, Protein: 70}, {KCal: 2300, Fat: 55, Carbs: 250, Protein: 75}, {KCal: 2400, Fat: 60, Carbs: 260, Protein: 80}, {KCal: 2500, Fat: 65, Carbs: 270, Protein: 85}, {KCal: 2600, Fat: 70, Carbs: 280, Protein: 90}, }, UIPrefs: app.UIPrefs{ NeutralCharts: true, }, } )
View Source
var (
ErrDOS = errors.New("dos")
)
Error definitions
View Source
var (
ErrFailSessionDestroy = errors.New("faildestroy")
)
View Source
var (
ErrMarshalFail = errors.New("fail")
)
Error definitions
Functions ¶
func Diary210101 ¶
func Diary210102 ¶
func Diary210201 ¶
func Diary210202 ¶
func Diary220301 ¶
func Diary220302 ¶
func Diary220312 ¶
func Diary220313 ¶
func Entry1 ¶
func Entry1() core.DiaryEntry
func Entry1New ¶
func Entry1New() core.DiaryEntry
func Entry1Rec1 ¶
func Entry1Rec1() core.DiaryEntry
func Entry2 ¶
func Entry2() core.DiaryEntry
func Entry2New ¶
func Entry2New() core.DiaryEntry
func Entry2Rec1 ¶
func Entry2Rec1() core.DiaryEntry
func Entry3 ¶
func Entry3() core.DiaryEntry
func Entry3New ¶
func Entry3New() core.DiaryEntry
func Entry4 ¶
func Entry4() core.DiaryEntry
func Entry4New ¶
func Entry4New() core.DiaryEntry
Types ¶
type DB ¶
type DB struct { User app.User Prefs app.StoredPrefs Tok app.Token FoodItem core.Food FoodItems []core.Food RecipeItem core.Recipe RecipeItems []core.Recipe Entries []core.DiaryEntry Days []core.DiaryDay ShopList []core.ShopItem Access Access Instructions Instructions Err []error ID int Name string Filter core.Filter // contains filtered or unexported fields }
func (*DB) DelDiaryEntries ¶
func (db *DB) DelDiaryEntries(id int, entries ...core.DiaryEntry) error
func (*DB) DelRecipeInstructions ¶
func (*DB) DiaryEntries ¶
func (*DB) NewDiaryEntries ¶
func (db *DB) NewDiaryEntries(id int, entries ...core.DiaryEntry) error
func (*DB) SetDiaryEntries ¶
func (db *DB) SetDiaryEntries(id int, entries ...core.DiaryEntry) error
func (*DB) SetRecipeAccess ¶
func (*DB) SetUserPrefs ¶
func (db *DB) SetUserPrefs(id int, prefs app.StoredPrefs) error
func (*DB) ShoppingList ¶
func (*DB) WithAccess ¶
func (*DB) WithEntries ¶
func (db *DB) WithEntries(ents ...core.DiaryEntry) *DB
type EmailNotifier ¶
func NewEmailNotifier ¶
func NewEmailNotifier() *EmailNotifier
func (*EmailNotifier) WithError ¶
func (e *EmailNotifier) WithError(err error) *EmailNotifier
type Handler ¶
type Handler struct {
Body string
}
func (Handler) Handle ¶
func (h Handler) Handle() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
type Instructions ¶
type MarshalFailer ¶
type MarshalFailer struct{}
func (MarshalFailer) MarshalJSON ¶
func (t MarshalFailer) MarshalJSON() ([]byte, error)
type Notifier ¶
type Notifier struct { To string Msg app.Notification Data app.NotificationData Err error }
func NewNotifier ¶
func NewNotifier() *Notifier
func (*Notifier) Send ¶
func (n *Notifier) Send(to string, msg app.Notification, data app.NotificationData) error
type SessionStore ¶
func NewSessionStore ¶
func NewSessionStore() *SessionStore
func (*SessionStore) DeleteCtx ¶
func (s *SessionStore) DeleteCtx(ctx context.Context, token string) error
func (*SessionStore) WithFailDestroy ¶
func (s *SessionStore) WithFailDestroy() *SessionStore
type Translator ¶
func NewTranslator ¶
func NewTranslator() *Translator
func (*Translator) Default ¶
func (t *Translator) Default() string
func (*Translator) Get ¶
func (t *Translator) Get(lang string) map[string]interface{}
func (*Translator) Translate ¶
func (t *Translator) Translate(input interface{}, lang string) string
Click to show internal directories.
Click to hide internal directories.