mirror of
https://github.com/fluxcd/flagger.git
synced 2026-02-27 16:23:53 +00:00
Add Promoted status condition with the following reasons: Initialized, Progressing, Succeeded, Failed Usage: `kubectl wait canary/app --for=condition=promoted` Fix: #184
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package controller
|
|
|
|
import (
|
|
flaggerv1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha3"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestCallWebhook(t *testing.T) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.WriteHeader(http.StatusAccepted)
|
|
}))
|
|
defer ts.Close()
|
|
hook := flaggerv1.CanaryWebhook{
|
|
Name: "validation",
|
|
URL: ts.URL,
|
|
Timeout: "10s",
|
|
Metadata: &map[string]string{"key1": "val1"},
|
|
}
|
|
|
|
err := CallWebhook("podinfo", "default", flaggerv1.CanaryPhaseProgressing, hook)
|
|
if err != nil {
|
|
t.Fatal(err.Error())
|
|
}
|
|
}
|
|
|
|
func TestCallWebhook_StatusCode(t *testing.T) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
}))
|
|
defer ts.Close()
|
|
hook := flaggerv1.CanaryWebhook{
|
|
Name: "validation",
|
|
URL: ts.URL,
|
|
}
|
|
|
|
err := CallWebhook("podinfo", "default", flaggerv1.CanaryPhaseProgressing, hook)
|
|
if err == nil {
|
|
t.Errorf("Got no error wanted %v", http.StatusInternalServerError)
|
|
}
|
|
}
|