refactor tests: simplify assertion

This commit is contained in:
mathetake
2020-03-04 21:46:08 +09:00
parent c42c624763
commit a616199b81
39 changed files with 937 additions and 2542 deletions
+6 -12
View File
@@ -7,6 +7,8 @@ import (
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -26,9 +28,7 @@ func TestCallWebhook(t *testing.T) {
}
err := CallWebhook("podinfo", v1.NamespaceDefault, flaggerv1.CanaryPhaseProgressing, hook)
if err != nil {
t.Fatal(err.Error())
}
require.NoError(t, err)
}
func TestCallWebhook_StatusCode(t *testing.T) {
@@ -42,9 +42,7 @@ func TestCallWebhook_StatusCode(t *testing.T) {
}
err := CallWebhook("podinfo", v1.NamespaceDefault, flaggerv1.CanaryPhaseProgressing, hook)
if err == nil {
t.Errorf("Got no error wanted %v", http.StatusInternalServerError)
}
assert.Error(t, err)
}
func TestCallEventWebhook(t *testing.T) {
@@ -99,9 +97,7 @@ func TestCallEventWebhook(t *testing.T) {
}
err := CallEventWebhook(canary, ts.URL, canaryMessage, canaryEventType)
if err != nil {
t.Fatal(err.Error())
}
require.NoError(t, err)
}
func TestCallEventWebhookStatusCode(t *testing.T) {
@@ -126,7 +122,5 @@ func TestCallEventWebhookStatusCode(t *testing.T) {
}
err := CallEventWebhook(canary, ts.URL, canaryMessage, canaryEventType)
if err == nil {
t.Errorf("Got no error wanted %v", http.StatusInternalServerError)
}
assert.Error(t, err)
}