fix: Unit test
parent
abbacf0b6e
commit
04cff2a8d2
|
@ -22,27 +22,28 @@ func TestSize_UnmarshalText(t *testing.T) {
|
||||||
{"1", 1},
|
{"1", 1},
|
||||||
{"10", 10},
|
{"10", 10},
|
||||||
{"100", 100},
|
{"100", 100},
|
||||||
{"1k", 1 << 10},
|
{"1kib", 1 << 10},
|
||||||
{"10k", 10 << 10},
|
{"10kib", 10 << 10},
|
||||||
{"100k", 100 << 10},
|
{"100kib", 100 << 10},
|
||||||
{"1K", 1 << 10},
|
{"1Kib", 1 << 10},
|
||||||
{"10K", 10 << 10},
|
{"10Kib", 10 << 10},
|
||||||
{"100K", 100 << 10},
|
{"100Kib", 100 << 10},
|
||||||
{"1m", 1 << 20},
|
{"1mib", 1 << 20},
|
||||||
{"10m", 10 << 20},
|
{"10mib", 10 << 20},
|
||||||
{"100m", 100 << 20},
|
{"100mib", 100 << 20},
|
||||||
{"1M", 1 << 20},
|
{"1Mib", 1 << 20},
|
||||||
{"10M", 10 << 20},
|
{"10Mib", 10 << 20},
|
||||||
{"100M", 100 << 20},
|
{"100Mib", 100 << 20},
|
||||||
{"1g", 1 << 30},
|
{"1gib", 1 << 30},
|
||||||
{"1G", 1 << 30},
|
{"1Gib", 1 << 30},
|
||||||
{fmt.Sprint(uint64(math.MaxUint64) - 1), math.MaxUint64 - 1},
|
{"100Gib", 100 << 30},
|
||||||
|
{"1tib", 1 << 40},
|
||||||
} {
|
} {
|
||||||
if err := s.UnmarshalText([]byte(test.str)); err != nil {
|
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) {
|
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)),
|
fmt.Sprintf("%dk", uint64(math.MaxUint64-1)),
|
||||||
"10000000000000000000g",
|
"10000000000000000000g",
|
||||||
"abcdef",
|
"abcdef",
|
||||||
"1KB",
|
|
||||||
"√m",
|
"√m",
|
||||||
"a1",
|
"a1",
|
||||||
"",
|
"",
|
||||||
} {
|
} {
|
||||||
if err := s.UnmarshalText([]byte(str)); err == nil {
|
if err := s.UnmarshalText([]byte(str)); err == nil {
|
||||||
t.Fatalf("input should have failed: %s", str)
|
t.Errorf("input should have failed: %s", str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,8 +118,8 @@ func TestConfig_HumanReadableSizes(t *testing.T) {
|
||||||
dir = "/var/lib/influxdb/data"
|
dir = "/var/lib/influxdb/data"
|
||||||
wal-dir = "/var/lib/influxdb/wal"
|
wal-dir = "/var/lib/influxdb/wal"
|
||||||
wal-fsync-delay = "10s"
|
wal-fsync-delay = "10s"
|
||||||
cache-max-memory-size = "5g"
|
cache-max-memory-size = "5gib"
|
||||||
cache-snapshot-memory-size = "100m"
|
cache-snapshot-memory-size = "100mib"
|
||||||
`, &c); err != nil {
|
`, &c); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue