Skip to content

Commit

Permalink
Adding test
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Kwasniewski <[email protected]>
  • Loading branch information
Kwasniewski committed Oct 18, 2023
1 parent 7fa50da commit 3c2c89d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/controller/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,29 @@ func TestCanaryChecksum(t *testing.T) {
require.NotEqual(t, canary3sum, canary1sum)
require.NotEqual(t, canary4sum, canary1sum)
}

func TestCallWebhook_Retries(t *testing.T) {
retries := 1
failures := 0
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if failures <= retries-1 {
w.WriteHeader(http.StatusInternalServerError)
failures++
} else {
w.WriteHeader(http.StatusAccepted)
}
}))
defer ts.Close()
hook := flaggerv1.CanaryWebhook{
Name: "validation",
URL: ts.URL,
Retries: retries,
}

err := CallWebhook(
flaggerv1.Canary{
ObjectMeta: metav1.ObjectMeta{
Name: "podinfo", Namespace: corev1.NamespaceDefault}},
flaggerv1.CanaryPhaseProgressing, hook)
require.NoError(t, err)
}

0 comments on commit 3c2c89d

Please sign in to comment.