Skip to content

Commit

Permalink
Support nil summaries
Browse files Browse the repository at this point in the history
  • Loading branch information
angelini committed May 19, 2022
1 parent 5488df9 commit d0ea4a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 4 additions & 0 deletions pkg/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ func walkChan(dir string, ignores []string) <-chan *Message {
func summaryChan(summary *pb.Summary) <-chan *Message {
channel := make(chan *Message, 100)

if summary == nil {
summary = &pb.Summary{}
}

go func() {
defer close(channel)

Expand Down
18 changes: 7 additions & 11 deletions test/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import (
"github.com/gadget-inc/fsdiff/pkg/pb"
)

var (
emptySummary = pb.Summary{}
)

func writeTmpFiles(t *testing.T, files map[string]string) string {
dir, err := os.MkdirTemp("", "dateilager_tests_")
if err != nil {
Expand Down Expand Up @@ -153,7 +149,7 @@ func TestDiffWithoutSummary(t *testing.T) {
})
defer os.RemoveAll(tmpDir)

d1, s1, err := diff.Diff(tmpDir, nil, &emptySummary)
d1, s1, err := diff.Diff(tmpDir, nil, nil)
if err != nil {
t.Fatalf("failed to run diff: %v", err)
}
Expand All @@ -179,7 +175,7 @@ func TestDiffWithSummary(t *testing.T) {
})
defer os.RemoveAll(tmpDir)

_, s1, err := diff.Diff(tmpDir, nil, &emptySummary)
_, s1, err := diff.Diff(tmpDir, nil, nil)
if err != nil {
t.Fatalf("failed to run diff: %v", err)
}
Expand Down Expand Up @@ -216,7 +212,7 @@ func TestDiffWithIgnores(t *testing.T) {
})
defer os.RemoveAll(tmpDir)

d1, s1, err := diff.Diff(tmpDir, []string{".ignore_1", ".ignore_2"}, &emptySummary)
d1, s1, err := diff.Diff(tmpDir, []string{".ignore_1", ".ignore_2"}, nil)
if err != nil {
t.Fatalf("failed to run diff: %v", err)
}
Expand Down Expand Up @@ -260,7 +256,7 @@ func TestDiffWithSymlinks(t *testing.T) {

createLink(t, tmpDir, "b", "c")

d1, s1, err := diff.Diff(tmpDir, nil, &emptySummary)
d1, s1, err := diff.Diff(tmpDir, nil, nil)
if err != nil {
t.Fatalf("failed to run diff: %v", err)
}
Expand Down Expand Up @@ -305,7 +301,7 @@ func TestDiffWithDirectories(t *testing.T) {
})
defer os.RemoveAll(tmpDir)

d1, s1, err := diff.Diff(tmpDir, nil, &emptySummary)
d1, s1, err := diff.Diff(tmpDir, nil, nil)
if err != nil {
t.Fatalf("failed to run diff: %v", err)
}
Expand Down Expand Up @@ -361,7 +357,7 @@ func TestDiffWithEmptyDirectories(t *testing.T) {

createDir(t, tmpDir, "e")

d1, s1, err := diff.Diff(tmpDir, nil, &emptySummary)
d1, s1, err := diff.Diff(tmpDir, nil, nil)
if err != nil {
t.Fatalf("failed to run diff: %v", err)
}
Expand Down Expand Up @@ -410,7 +406,7 @@ func TestDiffWithFileMove(t *testing.T) {
})
defer os.RemoveAll(tmpDir)

_, s1, err := diff.Diff(tmpDir, nil, &emptySummary)
_, s1, err := diff.Diff(tmpDir, nil, nil)
if err != nil {
t.Fatalf("failed to run diff: %v", err)
}
Expand Down

0 comments on commit d0ea4a9

Please sign in to comment.