fix: Unit test

pull/19508/head
Stuart Carnie 2020-09-04 14:53:50 -07:00
parent abbacf0b6e
commit 04cff2a8d2
2 changed files with 21 additions and 21 deletions

View File

@ -22,27 +22,28 @@ func TestSize_UnmarshalText(t *testing.T) {
{"1", 1},
{"10", 10},
{"100", 100},
{"1k", 1 << 10},
{"10k", 10 << 10},
{"100k", 100 << 10},
{"1K", 1 << 10},
{"10K", 10 << 10},
{"100K", 100 << 10},
{"1m", 1 << 20},
{"10m", 10 << 20},
{"100m", 100 << 20},
{"1M", 1 << 20},
{"10M", 10 << 20},
{"100M", 100 << 20},
{"1g", 1 << 30},
{"1G", 1 << 30},
{fmt.Sprint(uint64(math.MaxUint64) - 1), math.MaxUint64 - 1},
{"1kib", 1 << 10},
{"10kib", 10 << 10},
{"100kib", 100 << 10},
{"1Kib", 1 << 10},
{"10Kib", 10 << 10},
{"100Kib", 100 << 10},
{"1mib", 1 << 20},
{"10mib", 10 << 20},
{"100mib", 100 << 20},
{"1Mib", 1 << 20},
{"10Mib", 10 << 20},
{"100Mib", 100 << 20},
{"1gib", 1 << 30},
{"1Gib", 1 << 30},
{"100Gib", 100 << 30},
{"1tib", 1 << 40},
} {
if err := s.UnmarshalText([]byte(test.str)); err != nil {
t.Fatalf("unexpected error: %s", err)
t.Errorf("unexpected error: %s", err)
}
if s != itoml.Size(test.want) {
t.Fatalf("wanted: %d got: %d", test.want, s)
t.Errorf("wanted: %d got: %d", test.want, s)
}
}
@ -50,13 +51,12 @@ func TestSize_UnmarshalText(t *testing.T) {
fmt.Sprintf("%dk", uint64(math.MaxUint64-1)),
"10000000000000000000g",
"abcdef",
"1KB",
"√m",
"a1",
"",
} {
if err := s.UnmarshalText([]byte(str)); err == nil {
t.Fatalf("input should have failed: %s", str)
t.Errorf("input should have failed: %s", str)
}
}
}

View File

@ -118,8 +118,8 @@ func TestConfig_HumanReadableSizes(t *testing.T) {
dir = "/var/lib/influxdb/data"
wal-dir = "/var/lib/influxdb/wal"
wal-fsync-delay = "10s"
cache-max-memory-size = "5g"
cache-snapshot-memory-size = "100m"
cache-max-memory-size = "5gib"
cache-snapshot-memory-size = "100mib"
`, &c); err != nil {
t.Fatal(err)
}