-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f121cd5
commit 0f17df2
Showing
12 changed files
with
329 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,6 @@ scraped/ | |
cover.out | ||
ginkgo.report | ||
|
||
config.properties | ||
config.properties | ||
|
||
*.gob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package v1 | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestChangeSummary_Merge(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
summary1 ChangeSummary | ||
summary2 ChangeSummary | ||
expected ChangeSummary | ||
}{ | ||
{ | ||
name: "merge empty summaries", | ||
summary1: ChangeSummary{}, | ||
summary2: ChangeSummary{}, | ||
expected: ChangeSummary{}, | ||
}, | ||
{ | ||
name: "merge summaries with orphaned changes", | ||
summary1: ChangeSummary{ | ||
Orphaned: map[string]int{ | ||
"foo": 1, | ||
"bar": 2, | ||
}, | ||
}, | ||
summary2: ChangeSummary{ | ||
Orphaned: map[string]int{ | ||
"foo": 3, | ||
"baz": 4, | ||
}, | ||
}, | ||
expected: ChangeSummary{ | ||
Orphaned: map[string]int{ | ||
"foo": 4, | ||
"bar": 2, | ||
"baz": 4, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "merge summaries with ignored changes", | ||
summary1: ChangeSummary{ | ||
Ignored: map[string]int{ | ||
"foo": 1, | ||
"bar": 2, | ||
}, | ||
}, | ||
summary2: ChangeSummary{ | ||
Ignored: map[string]int{ | ||
"foo": 3, | ||
"baz": 4, | ||
}, | ||
}, | ||
expected: ChangeSummary{ | ||
Ignored: map[string]int{ | ||
"foo": 4, | ||
"bar": 2, | ||
"baz": 4, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "merge summaries with both orphaned and ignored changes", | ||
summary1: ChangeSummary{ | ||
Orphaned: map[string]int{ | ||
"foo": 1, | ||
"bar": 2, | ||
}, | ||
Ignored: map[string]int{ | ||
"baz": 3, | ||
"qux": 4, | ||
}, | ||
}, | ||
summary2: ChangeSummary{ | ||
Orphaned: map[string]int{ | ||
"foo": 5, | ||
"quux": 6, | ||
}, | ||
Ignored: map[string]int{ | ||
"baz": 7, | ||
"corge": 8, | ||
}, | ||
}, | ||
expected: ChangeSummary{ | ||
Orphaned: map[string]int{ | ||
"foo": 6, | ||
"bar": 2, | ||
"quux": 6, | ||
}, | ||
Ignored: map[string]int{ | ||
"baz": 10, | ||
"qux": 4, | ||
"corge": 8, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
tt.summary1.Merge(tt.summary2) | ||
if len(tt.summary1.Orphaned) != len(tt.expected.Orphaned) { | ||
t.Errorf("Expected %d orphaned changes, got %d", len(tt.expected.Orphaned), len(tt.summary1.Orphaned)) | ||
} | ||
for k, v := range tt.expected.Orphaned { | ||
if tt.summary1.Orphaned[k] != v { | ||
t.Errorf("Expected %d orphaned changes for %s, got %d", v, k, tt.summary1.Orphaned[k]) | ||
} | ||
} | ||
if len(tt.summary1.Ignored) != len(tt.expected.Ignored) { | ||
t.Errorf("Expected %d ignored changes, got %d", len(tt.expected.Ignored), len(tt.summary1.Ignored)) | ||
} | ||
for k, v := range tt.expected.Ignored { | ||
if tt.summary1.Ignored[k] != v { | ||
t.Errorf("Expected %d ignored changes for %s, got %d", v, k, tt.summary1.Ignored[k]) | ||
} | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.