Skip to content

Commit

Permalink
fix: Unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcarnie committed Sep 4, 2020
1 parent 3745c04 commit 7fbb4e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
38 changes: 19 additions & 19 deletions toml/toml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,41 @@ 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)
}
}

for _, str := range []string{
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)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tsdb/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 7fbb4e1

Please sign in to comment.