Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
Fixed equals.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkleinhenz committed Aug 27, 2018
1 parent 649ef2a commit 58f5187
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions actions/rules/action_state_to_metastate_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package rules

import (
"fmt"
"testing"

"github.com/fabric8-services/fabric8-wit/actions/change"
Expand All @@ -24,18 +23,6 @@ type ActionStateToMetastateSuite struct {
gormtestsupport.DBTestSuite
}

func ArrayEquals(a []interface{}, b []interface{}) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}

func (s *ActionStateToMetastateSuite) TestContainsElement() {
s.T().Run("contains an element", func(t *testing.T) {
fxt := tf.NewTestFixture(t, s.DB, tf.CreateWorkItemEnvironment())
Expand Down Expand Up @@ -75,11 +62,11 @@ func (s *ActionStateToMetastateSuite) TestRemoveElement() {
a = action.removeElement(a, 1)
expected := []interface{}{0, 2, 3, 2}
require.Len(t, a, 4)
require.True(t, ArrayEquals(expected, a))
require.Equal(t, expected, a)
a = action.removeElement(a, 3)
expected = []interface{}{0, 2, 2}
require.Len(t, a, 3)
require.True(t, ArrayEquals(expected, a))
require.Equal(t, expected, a)
})
s.T().Run("removing a non-existing element", func(t *testing.T) {
fxt := tf.NewTestFixture(t, s.DB, tf.CreateWorkItemEnvironment())
Expand All @@ -92,7 +79,7 @@ func (s *ActionStateToMetastateSuite) TestRemoveElement() {
a = action.removeElement(a, 4)
require.Len(t, a, 5)
expected := []interface{}{0, 1, 2, 3, 2}
require.True(t, ArrayEquals(expected, a))
require.Equal(t, expected, a)
})
s.T().Run("removing a duplicate element", func(t *testing.T) {
fxt := tf.NewTestFixture(t, s.DB, tf.CreateWorkItemEnvironment())
Expand All @@ -105,7 +92,7 @@ func (s *ActionStateToMetastateSuite) TestRemoveElement() {
a = action.removeElement(a, 2)
expected := []interface{}{0, 1, 3}
require.Len(t, a, 3)
require.True(t, ArrayEquals(expected, a))
require.Equal(t, expected, a)
})
}

Expand All @@ -128,8 +115,8 @@ func (s *ActionStateToMetastateSuite) TestDifference() {
var expectedRemoved []interface{}
expectedRemoved = append(expectedRemoved, 0)
expectedRemoved = append(expectedRemoved, 1)
require.True(t, ArrayEquals(added, expectedAdded))
require.True(t, ArrayEquals(removed, expectedRemoved))
require.Equal(t, added, expectedAdded)
require.Equal(t, removed, expectedRemoved)
})
}

Expand Down

0 comments on commit 58f5187

Please sign in to comment.