diff --git a/commands/activations_test.go b/commands/activations_test.go index ed30042ca..930dd9754 100644 --- a/commands/activations_test.go +++ b/commands/activations_test.go @@ -16,7 +16,6 @@ package commands import ( "bytes" "errors" - "sort" "strconv" "strings" "testing" @@ -37,9 +36,7 @@ func TestActivationsCommand(t *testing.T) { names = append(names, c.Name()) } - sort.Strings(expected) - sort.Strings(names) - assert.Equal(t, expected, names) + assert.ElementsMatch(t, expected, names) } var hello1Result = whisk.Result(map[string]interface{}{ diff --git a/commands/commands_test.go b/commands/commands_test.go index e5413e4ac..0991468ec 100644 --- a/commands/commands_test.go +++ b/commands/commands_test.go @@ -15,7 +15,6 @@ package commands import ( "io" - "sort" "testing" "github.com/digitalocean/doctl" @@ -140,9 +139,7 @@ func assertCommandNames(t *testing.T, cmd *Command, expected ...string) { } } - sort.Strings(expected) - sort.Strings(names) - assert.Equal(t, expected, names) + assert.ElementsMatch(t, expected, names) } type testFn func(c *CmdConfig, tm *tcMocks) diff --git a/commands/functions_test.go b/commands/functions_test.go index eb86d05fd..d989ffacb 100644 --- a/commands/functions_test.go +++ b/commands/functions_test.go @@ -16,7 +16,6 @@ package commands import ( "bytes" "os" - "sort" "strings" "testing" "time" @@ -37,9 +36,7 @@ func TestFunctionsCommand(t *testing.T) { names = append(names, c.Name()) } - sort.Strings(expected) - sort.Strings(names) - assert.Equal(t, expected, names) + assert.ElementsMatch(t, expected, names) } func TestFunctionsGet(t *testing.T) { diff --git a/commands/namespaces_test.go b/commands/namespaces_test.go index 57a9cb0fb..83a0c0620 100644 --- a/commands/namespaces_test.go +++ b/commands/namespaces_test.go @@ -17,7 +17,6 @@ import ( "bytes" "context" "errors" - "sort" "testing" "github.com/digitalocean/doctl/do" @@ -35,9 +34,7 @@ func TestNamespacesCommand(t *testing.T) { names = append(names, c.Name()) } - sort.Strings(expected) - sort.Strings(names) - assert.Equal(t, expected, names) + assert.ElementsMatch(t, expected, names) } func TestNamespacesCreate(t *testing.T) { diff --git a/commands/triggers_test.go b/commands/triggers_test.go index ec9dc13cb..3989a3284 100644 --- a/commands/triggers_test.go +++ b/commands/triggers_test.go @@ -16,7 +16,6 @@ package commands import ( "bytes" "context" - "sort" "testing" "time" @@ -35,9 +34,7 @@ func TestTriggersCommand(t *testing.T) { names = append(names, c.Name()) } - sort.Strings(expected) - sort.Strings(names) - assert.Equal(t, expected, names) + assert.ElementsMatch(t, expected, names) } func TestTriggersGet(t *testing.T) { diff --git a/pkg/listen/listen_test.go b/pkg/listen/listen_test.go index 401a4a3d8..9727be246 100644 --- a/pkg/listen/listen_test.go +++ b/pkg/listen/listen_test.go @@ -23,9 +23,7 @@ var ( func wsHandler(t *testing.T) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { c, err := upgrader.Upgrade(w, r, nil) - if err != nil { - require.NoError(t, err) - } + require.NoError(t, err) defer c.Close() i := 0 finish := 5 @@ -43,9 +41,7 @@ func wsHandler(t *testing.T) http.HandlerFunc { json.NewEncoder(buf).Encode(data) err = c.WriteMessage(websocket.TextMessage, buf.Bytes()) - if err != nil { - require.NoError(t, err) - } + require.NoError(t, err) if i == finish { break @@ -60,17 +56,13 @@ func TestListener(t *testing.T) { u := "ws" + strings.TrimPrefix(server.URL, "http") url, err := url.Parse(u) - if err != nil { - require.NoError(t, err) - } + require.NoError(t, err) buffer := &bytes.Buffer{} listener := NewListener(url, "", nil, buffer) err = listener.Start() - if err != nil { - require.NoError(t, err) - } + require.NoError(t, err) want := `{"message":"1\n"} {"message":"2\n"} @@ -87,9 +79,7 @@ func TestListenerWithSchemaFunc(t *testing.T) { u := "ws" + strings.TrimPrefix(server.URL, "http") url, err := url.Parse(u) - if err != nil { - require.NoError(t, err) - } + require.NoError(t, err) buffer := &bytes.Buffer{} @@ -108,9 +98,7 @@ func TestListenerWithSchemaFunc(t *testing.T) { listener := NewListener(url, "", schemaFunc, buffer) err = listener.Start() - if err != nil { - t.Fatalf("%v", err) - } + require.NoError(t, err) want := `1 2 @@ -127,9 +115,7 @@ func TestListenerStop(t *testing.T) { u := "ws" + strings.TrimPrefix(server.URL, "http") url, err := url.Parse(u) - if err != nil { - require.NoError(t, err) - } + require.NoError(t, err) buffer := &bytes.Buffer{}