featurebase/server/config_test.go
reesporte 48aef0c8a4 add copyright notice back in
```bash
for file in `cat diffys`; do
   printf '%s\n%s\n' "// Copyright 2021 Molecula Corp. All rights reserved." "$(cat $file)" >$file;
done
```
2021-12-10 11:01:04 -06:00

43 lines
896 B
Go

// Copyright 2021 Molecula Corp. All rights reserved.
package server_test
import (
"reflect"
"testing"
"time"
"github.com/molecula/featurebase/v2/server"
"github.com/molecula/featurebase/v2/toml"
)
func Test_ValidateConfig(t *testing.T) {
c := server.NewConfig()
c.MustValidate()
}
func TestDuration(t *testing.T) {
d := toml.Duration(time.Second * 182)
if d.String() != "3m2s" {
t.Fatalf("Unexpected time Duration %s", d)
}
b := []byte{51, 109, 50, 115}
v, _ := d.MarshalText()
if !reflect.DeepEqual(b, v) {
t.Fatalf("Unexpected marshalled value %v", v)
}
v, _ = d.MarshalTOML()
if !reflect.DeepEqual(b, v) {
t.Fatalf("Unexpected marshalled value %v", v)
}
err := d.UnmarshalText([]byte("3m2s"))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
v, _ = d.MarshalText()
if !reflect.DeepEqual(b, v) {
t.Fatalf("Unexpected marshalled value %v", v)
}
}