/
mock_db.go
44 lines (36 loc) · 1.11 KB
/
mock_db.go
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
40
41
42
43
44
// Copyright 2020, Square, Inc.
package test
import (
"context"
"github.com/square/rotate-password-lambda/db"
)
type MockPasswordSetter struct {
InitFunc func(context.Context, map[string]string) error
SetPasswordFunc func(ctx context.Context, creds db.NewPassword) error
VerifyPasswordFunc func(ctx context.Context, creds db.NewPassword) error
RollBackFunc func(ctx context.Context, creds db.NewPassword) error
}
func (m MockPasswordSetter) Init(ctx context.Context, s map[string]string) error {
if m.InitFunc != nil {
return m.InitFunc(ctx, s)
}
return nil
}
func (m MockPasswordSetter) SetPassword(ctx context.Context, creds db.NewPassword) error {
if m.SetPasswordFunc != nil {
return m.SetPasswordFunc(ctx, creds)
}
return nil
}
func (m MockPasswordSetter) VerifyPassword(ctx context.Context, creds db.NewPassword) error {
if m.VerifyPasswordFunc != nil {
return m.VerifyPasswordFunc(ctx, creds)
}
return nil
}
func (m MockPasswordSetter) RollBack(ctx context.Context, creds db.NewPassword) error {
if m.RollBackFunc != nil {
return m.RollBackFunc(ctx, creds)
}
return nil
}