summaryrefslogtreecommitdiffstats
path: root/stdout
diff options
context:
space:
mode:
Diffstat (limited to 'stdout')
-rw-r--r--stdout/stdout.go6
-rw-r--r--stdout/stdout_test.go13
2 files changed, 18 insertions, 1 deletions
diff --git a/stdout/stdout.go b/stdout/stdout.go
index e98fc10..e675abd 100644
--- a/stdout/stdout.go
+++ b/stdout/stdout.go
@@ -265,7 +265,11 @@ func (ui *UI) ReadAnalysis(input io.Reader) error {
return err
}
- ui.showDir(dir)
+ if ui.summarize {
+ ui.printTotalItem(dir)
+ } else {
+ ui.showDir(dir)
+ }
return nil
}
diff --git a/stdout/stdout_test.go b/stdout/stdout_test.go
index 5a95dc4..425765b 100644
--- a/stdout/stdout_test.go
+++ b/stdout/stdout_test.go
@@ -186,6 +186,19 @@ func TestReadAnalysisWithWrongFile(t *testing.T) {
assert.NotNil(t, err)
}
+func TestReadAnalysisWithSummarize(t *testing.T) {
+ input, err := os.OpenFile("../internal/testdata/test.json", os.O_RDONLY, 0644)
+ assert.Nil(t, err)
+
+ output := bytes.NewBuffer(make([]byte, 10))
+
+ ui := CreateStdoutUI(output, false, false, false, false, true, false, false)
+ err = ui.ReadAnalysis(input)
+
+ assert.Nil(t, err)
+ assert.Contains(t, output.String(), " gdu\n")
+}
+
func TestMaxInt(t *testing.T) {
assert.Equal(t, 5, maxInt(2, 5))
assert.Equal(t, 4, maxInt(4, 2))