-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathconfig_test.go
65 lines (62 loc) · 1.66 KB
/
config_test.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
58
59
60
61
62
63
64
65
package config
import (
"reflect"
"testing"
"time"
"github.com/raystack/frontier/internal/store/spicedb"
"github.com/raystack/frontier/pkg/db"
)
func TestLoad(t *testing.T) {
type args struct {
serverConfigFileFromFlag string
}
tests := []struct {
name string
args args
want *Frontier
wantErr bool
}{
{
name: "load yaml file successfully while parsing time.Duration value",
args: args{
serverConfigFileFromFlag: "testdata/use_duration.yaml",
},
want: &Frontier{
Version: 1,
DB: db.Config{
Driver: "postgres",
URL: "postgres://frontier:@localhost:5432/frontier?sslmode=disable",
MaxIdleConns: 10,
MaxOpenConns: 10,
ConnMaxLifeTime: time.Duration(10) * time.Millisecond,
MaxQueryTimeout: time.Duration(500) * time.Millisecond,
},
SpiceDB: spicedb.Config{
Host: "spicedb.localhost",
Port: "50051",
PreSharedKey: "randomkey",
Consistency: spicedb.ConsistencyLevelBestEffort.String(),
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Load(tt.args.serverConfigFileFromFlag)
if (err != nil) != tt.wantErr {
t.Errorf("Load() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got.Version, tt.want.Version) {
t.Errorf("Load() got = %v\nwant %v", got.Version, tt.want.Version)
}
if !reflect.DeepEqual(got.DB, tt.want.DB) {
t.Errorf("Load() got = %v\nwant %v", got.DB, tt.want.DB)
}
if !reflect.DeepEqual(got.SpiceDB, tt.want.SpiceDB) {
t.Errorf("Load() got = %v\nwant %v", got.SpiceDB, tt.want.SpiceDB)
}
})
}
}