Skip to content

Commit

Permalink
cmds/core/du: add run test
Browse files Browse the repository at this point in the history
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
  • Loading branch information
binjip978 committed Aug 20, 2024
1 parent 1c579b3 commit 4c38e06
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cmds/core/du/du_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
package main

import (
"bytes"
"os"
"regexp"
"testing"
)

Expand Down Expand Up @@ -60,3 +62,24 @@ func TestDU(t *testing.T) {
}
})
}

func TestRun(t *testing.T) {
t.Run("empty folder", func(t *testing.T) {
dir := t.TempDir()
err := os.Chdir(dir)
if err != nil {
t.Fatal(err)
}

stdout := &bytes.Buffer{}
err = run(stdout)
if err != nil {
t.Fatalf("expected nil got %v", err)
}

r := regexp.MustCompile(`^\d\t\.\n$`)
if !r.MatchString(stdout.String()) {
t.Error("expected number tab dot new-line")
}
})
}

0 comments on commit 4c38e06

Please sign in to comment.