-
Notifications
You must be signed in to change notification settings - Fork 0
/
suspect.go
57 lines (48 loc) · 1.04 KB
/
suspect.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
45
46
47
48
49
50
51
52
53
54
55
56
57
package suspect
import (
"github.com/BurntSushi/toml"
"github.com/gavv/httpexpect/v2"
inbucket "github.com/inbucket/inbucket/pkg/rest/client"
"github.com/jackc/pgx/v4"
"github.com/stretchr/testify/require"
"testing"
"time"
)
type Suspect struct {
api *httpexpect.Expect
db *pgx.Conn
mail *inbucket.Client
t *testing.T
conf config
}
type config struct {
Api struct {
Port uint
}
Db struct {
Port uint
}
Inbucket struct {
Port uint
}
}
func NewSuspect(t *testing.T) *Suspect {
var conf config
_, err := toml.DecodeFile("./supabase/config.toml", &conf)
require.NoError(t, err)
ensureTestEnvironment(t)
api := newApiClient(t, conf)
db := newDbConn(t, conf)
mail := newMailClient(t, conf)
return &Suspect{api, db, mail, t, conf}
}
func (s *Suspect) Slice() *Suspect {
api := newApiClient(s.t, s.conf)
return &Suspect{api, s.db, s.mail, s.t, s.conf}
}
func (s *Suspect) Wait(seconds int) *Suspect {
s.t.Helper()
s.t.Logf("Waiting for %d seconds", seconds)
time.Sleep(time.Duration(seconds) * time.Second)
return s
}