clean up of the codebase
This commit is contained in:
1 parent
7822529a38
commit
0ac61b4ece
52 files changed
+2545
-2274
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDriveMath(t *testing.T) {
|
||||
d := DriveReport{Path: "/a", UsableMB: 100_000, CommittedMB: 90_000, BookedMB: 150_000}
|
||||
if d.HeadroomMB() != 10_000 || !d.Overbooked() {
|
||||
t.Fatalf("headroom %d overbooked %v", d.HeadroomMB(), d.Overbooked())
|
||||
}
|
||||
if Committed(5120, 8000) != 8000 || Committed(5120, 100) != 5120 {
|
||||
t.Fatal("a home holds its guarantee or its real use, whichever is bigger")
|
||||
}
|
||||
drives := []DriveReport{d, {Path: "/b", UsableMB: 50_000, CommittedMB: 20_000}}
|
||||
if got, _ := PickDrive(drives, 5120); got != "/b" {
|
||||
t.Fatalf("should pick the drive with the most room, got %s", got)
|
||||
}
|
||||
if _, err := PickDrive(drives, 40_000); !errors.Is(err, ErrStorageFull) {
|
||||
t.Fatal("a guarantee that fits nowhere should be rejected")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseQgroupShow(t *testing.T) {
|
||||
out := "Qgroupid Referenced Exclusive Max referenced Max exclusive Path\n" +
|
||||
"-------- ---------- --------- -------------- ------------- ----\n" +
|
||||
"0/257 3221225472 3221225472 10737418240 none c-c07abc\n"
|
||||
if mb, err := parseQgroupShow(out); err != nil || mb != 3072 {
|
||||
t.Fatalf("got %d, %v", mb, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user