~evanj/cms

ref: 5eb977545bd0bfaacf289952a8b7f5a273168ab6 cms/internal/m/user/mock.go -rw-r--r-- 1.2 KiB
5eb97754Evan M Jones Chore(Error2 -> Error): Swapped Error impl. for Error2 in all 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package user

import (
	"git.sr.ht/~evanj/cms/internal/m/org"
	"git.sr.ht/~evanj/cms/internal/m/tier"
	"github.com/google/uuid"
)

type _user struct {
	id, name, tok, email string
	org                  _org
	pass                 string
}

type _org struct {
	id string
}

func NewMock(id, name string) _user {
	return _user{id, name, uuid.New().String(), "", _org{id}, ""}
}

func NewMockWithEmail(id, name, email string) _user {
	return _user{id, name, uuid.New().String(), email, _org{id}, ""}
}

func (u _user) ID() string             { return u.id }
func (u _user) Name() string           { return u.name }
func (u _user) Token() string          { return u.tok }
func (u _user) HasEmail() bool         { return u.email != "" }
func (u _user) Email() string          { return u.email }
func (u _user) Org() org.Org           { return u.org }
func (u _user) SetPass(p string) _user { u.pass = p; return u }
func (u _user) Pass() string           { return u.pass }

func (o _org) ID() string                { return o.id }
func (o _org) HasPaymentCustomer() bool  { return false }
func (o _org) PaymentCustomerID() string { return "" }
func (o _org) Tier() tier.Tier           { return tier.Free }