forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_test.go
45 lines (34 loc) · 907 Bytes
/
service_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
package kv_test
import (
"context"
"io"
"testing"
"time"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kv"
"go.uber.org/zap/zaptest"
)
type mockStore struct {
}
func (s mockStore) View(context.Context, func(kv.Tx) error) error {
return nil
}
func (s mockStore) Update(context.Context, func(kv.Tx) error) error {
return nil
}
func (s mockStore) Backup(ctx context.Context, w io.Writer) error {
return nil
}
func TestNewService(t *testing.T) {
s := kv.NewService(zaptest.NewLogger(t), mockStore{})
if s.Config.SessionLength != influxdb.DefaultSessionLength {
t.Errorf("Service session length should use default length when not set")
}
config := kv.ServiceConfig{
SessionLength: time.Duration(time.Hour * 4),
}
s = kv.NewService(zaptest.NewLogger(t), mockStore{}, config)
if s.Config != config {
t.Errorf("Service config not set by constructor")
}
}