Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that the JSON matches. #666

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pkg/interceptors/cel/cel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cel

import (
"bytes"
"encoding/json"
"io"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -244,8 +245,9 @@ func TestInterceptor_ExecuteTrigger(t *testing.T) {
rt.Fatalf("error reading response body: %v", err)
}
defer resp.Body.Close()
if diff := cmp.Diff(tt.want, got); diff != "" {
rt.Errorf("Interceptor.ExecuteTrigger (-want, +got) = %s", diff)

if diff := cmp.Diff(mustUnmarshal(t, tt.want), mustUnmarshal(t, got)); diff != "" {
t.Errorf("Interceptor.ExecuteTrigger (-want, +got) = %s", diff)
}
})
}
Expand Down Expand Up @@ -685,3 +687,13 @@ func mustParseURL(t *testing.T, u string) *url.URL {
}
return parsed
}

func mustUnmarshal(t *testing.T, b []byte) map[string]interface{} {
t.Helper()
v := map[string]interface{}{}
err := json.Unmarshal(b, &v)
if err != nil {
t.Fatalf("failed to unmarshal the body '%s': %s", b, err)
}
return v
}