MCPcopy Create free account
hub / github.com/prometheus/procfs / TestParseCounterFileHumanReadable

Function TestParseCounterFileHumanReadable

bcachefs/get_test.go:93–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func 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}

Callers

nothing calls this directly

Calls 2

parseCounterFileFunction · 0.85
parseHumanReadableBytesFunction · 0.85

Tested by

no test coverage detected