github.com/anishathalye/periscope@v0.3.5/internal/periscope/summary_test.go (about) 1 package periscope 2 3 import ( 4 "github.com/anishathalye/periscope/internal/testfs" 5 6 "strings" 7 "testing" 8 ) 9 10 func TestSummaryBasic(t *testing.T) { 11 fs := testfs.Read(` 12 /d1/a [10000 1] 13 /d1/b [13923446 2] 14 /d1/c [1191 3] 15 /d2/a [10000 1] 16 /d2/b [13923446 2] 17 /d2/c [1002 5] 18 /d3/a [10000 1] 19 `).Mkfs() 20 ps, out, _ := newTest(fs) 21 ps.Scan([]string{"/"}, &ScanOptions{}) 22 err := ps.Summary(&SummaryOptions{}) 23 check(t, err) 24 got := strings.TrimSpace(out.String()) 25 expected := strings.TrimSpace(` 26 tracked 7 27 unique 4 28 duplicate 3 29 overhead 14 MB 30 `) 31 if got != expected { 32 t.Fatalf("expected '%s', got '%s'", expected, got) 33 } 34 } 35 36 func TestSummaryEmpty(t *testing.T) { 37 fs := testfs.New(nil).Mkfs() 38 ps, out, _ := newTest(fs) 39 err := ps.Summary(&SummaryOptions{}) 40 check(t, err) 41 got := strings.TrimSpace(out.String()) 42 expected := strings.TrimSpace(` 43 tracked 0 44 unique 0 45 duplicate 0 46 overhead 0 B 47 `) 48 if got != expected { 49 t.Fatalf("expected '%s', got '%s'", expected, got) 50 } 51 }