48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package toml_test
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/influxdb/influxdb/toml"
|
|
)
|
|
|
|
// Ensure that megabyte sizes can be parsed.
|
|
func TestSize_UnmarshalText_MB(t *testing.T) {
|
|
var s toml.Size
|
|
if err := s.UnmarshalText([]byte("200m")); err != nil {
|
|
t.Fatalf("unexpected error: %s", err)
|
|
} else if s != 200*(1<<20) {
|
|
t.Fatalf("unexpected size: %d", s)
|
|
}
|
|
}
|
|
|
|
// Ensure that gigabyte sizes can be parsed.
|
|
func TestSize_UnmarshalText_GB(t *testing.T) {
|
|
if typ := reflect.TypeOf(0); typ.Size() != 8 {
|
|
t.Skip("large gigabyte parsing on 64-bit arch only")
|
|
}
|
|
|
|
var s toml.Size
|
|
if err := s.UnmarshalText([]byte("10g")); err != nil {
|
|
t.Fatalf("unexpected error: %s", err)
|
|
} else if s != 10*(1<<30) {
|
|
t.Fatalf("unexpected size: %d", s)
|
|
}
|
|
}
|
|
|
|
/*
|
|
func TestConfig_Encode(t *testing.T) {
|
|
var c influxdb.Config
|
|
c.Monitoring.WriteInterval = influxdb.Duration(time.Minute)
|
|
buf := new(bytes.Buffer)
|
|
if err := toml.NewEncoder(buf).Encode(&c); err != nil {
|
|
t.Fatal("Failed to encode: ", err)
|
|
}
|
|
got, search := buf.String(), `write-interval = "1m0s"`
|
|
if !strings.Contains(got, search) {
|
|
t.Fatalf("Encoding config failed.\nfailed to find %s in:\n%s\n", search, got)
|
|
}
|
|
}
|
|
*/
|