(t *testing.T)
| 91 | } |
| 92 | |
| 93 | func TestParseCounterFileHumanReadable(t *testing.T) { |
| 94 | dir := t.TempDir() |
| 95 | path := filepath.Join(dir, "counter") |
| 96 | if err := os.WriteFile(path, []byte("since mount: 2.05G\nsince filesystem creation: 1.5T\n"), 0o644); err != nil { |
| 97 | t.Fatalf("write counter file: %v", err) |
| 98 | } |
| 99 | |
| 100 | got, err := parseCounterFile(path) |
| 101 | if err != nil { |
| 102 | t.Fatalf("parseCounterFile error: %v", err) |
| 103 | } |
| 104 | |
| 105 | wantMount, err := parseHumanReadableBytes("2.05G") |
| 106 | if err != nil { |
| 107 | t.Fatalf("parseHumanReadableBytes mount error: %v", err) |
| 108 | } |
| 109 | wantCreation, err := parseHumanReadableBytes("1.5T") |
| 110 | if err != nil { |
| 111 | t.Fatalf("parseHumanReadableBytes creation error: %v", err) |
| 112 | } |
| 113 | |
| 114 | if got.SinceMount != wantMount { |
| 115 | t.Fatalf("since mount = %d, want %d", got.SinceMount, wantMount) |
| 116 | } |
| 117 | if got.SinceFilesystemCreation != wantCreation { |
| 118 | t.Fatalf("since filesystem creation = %d, want %d", got.SinceFilesystemCreation, wantCreation) |
| 119 | } |
| 120 | } |
nothing calls this directly
no test coverage detected