Skip to content

Commit

Permalink
making tests robust
Browse files Browse the repository at this point in the history
  • Loading branch information
dareid committed Jun 4, 2018
1 parent 44419b8 commit 7489916
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions dep.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ type DepsByName []Dep
func (d DepsByName) Len() int { return len(d) }
func (d DepsByName) Swap(i, j int) { d[i], d[j] = d[j], d[i] }
func (d DepsByName) Less(i, j int) bool { return d[i].Name < d[j].Name }

type Warnings []Warning

func (d Warnings) Len() int { return len(d) }
func (d Warnings) Swap(i, j int) { d[i], d[j] = d[j], d[i] }
func (d Warnings) Less(i, j int) bool { return d[i].Warning() < d[j].Warning() }
8 changes: 6 additions & 2 deletions npm/npm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,12 @@ func TestDependencies(t *testing.T) {
t.Errorf("deps: got %+v, want %+v", d, expectedDeps)
}
}
if (len(w) > 0 || len(tt.warnsOut) > 0) && reflect.DeepEqual(w, tt.warnsOut) == false {
t.Errorf("warnings: got %+v, want %+v", w, tt.warnsOut)
if len(w) > 0 || len(tt.warnsOut) > 0 {
sort.Sort(diligent.Warnings(w))
sort.Sort(diligent.Warnings(tt.warnsOut))
if reflect.DeepEqual(w, tt.warnsOut) == false {
t.Errorf("warnings: got %+v, want %+v", w, tt.warnsOut)
}
}
isErr := e != nil
if tt.errOut != isErr {
Expand Down

0 comments on commit 7489916

Please sign in to comment.