Skip to content

Commit

Permalink
testリファクタ
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddddO committed Sep 30, 2023
1 parent 40ec868 commit 7a7c119
Showing 1 changed file with 36 additions and 19 deletions.
55 changes: 36 additions & 19 deletions internal/counter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,43 @@ import (
)

func TestCounter_Summary(t *testing.T) {
paths := []string{
"empty_directory/",
"a.txt",
"a.tgz",
"source/a.tgz",
"source/b.tgz",
"source/c.tgz",
"tmp_directory/",
"tmp_directory/a.png",
"tmp_directory/empty_directory/",
"tmp_directory/source/a.tgz",
tests := []struct {
name string
paths []string
want string
}{
{
name: "pattern1",
paths: []string{
"empty_directory/",
"a.txt",
"a.tgz",
"source/a.tgz",
"source/b.tgz",
"source/c.tgz",
"tmp_directory/",
"tmp_directory/a.png",
"tmp_directory/empty_directory/",
"tmp_directory/source/a.tgz",
},
want: "5 directories, 7 files",
},
}
want := "5 directories, 7 files"
c := newCounter()
for _, p := range paths {
c.count(p)
}
got := c.summary()

if got != want {
t.Errorf("\ngot: \n%s\nwant: \n%s", got, want)
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

c := newCounter()
for _, p := range tt.paths {
c.count(p)
}
got := c.summary()

if got != tt.want {
t.Errorf("\ngot: \n%s\nwant: \n%s", got, tt.want)
}
})
}
}

0 comments on commit 7a7c119

Please sign in to comment.