From b2339edd24db3127b525ef7d93b0e32a387435e2 Mon Sep 17 00:00:00 2001 From: Kevin McDermott Date: Wed, 21 Oct 2020 13:59:36 +0100 Subject: [PATCH] Drop escaping of strings in the JSON. Add support for the old escaping mechanism through an annotation on the TriggerTemptlate. This removes the old replacement of " with \" in parameters, which was yielding invalid JSON when the strings were already quoted. --- test/eventlistener_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/eventlistener_test.go b/test/eventlistener_test.go index 5e60f5e0a8..8154ce07d9 100644 --- a/test/eventlistener_test.go +++ b/test/eventlistener_test.go @@ -62,13 +62,13 @@ const ( examplePRJsonFilename = "pr.json" ) -func loadExamplePREventBytes() ([]byte, error) { +func loadExamplePREventBytes(t *testing.T) []byte { path := filepath.Join("testdata", examplePRJsonFilename) bytes, err := ioutil.ReadFile(path) if err != nil { - return nil, fmt.Errorf("couldn't load testdata example PullRequest event data: %v", err) + t.Fatalf("Couldn't load test data example PullREquest event data: %v", err) } - return bytes, nil + return bytes } func impersonateRBAC(t *testing.T, sa, namespace string, kubeClient kubernetes.Interface) { @@ -182,6 +182,9 @@ func TestEventListenerCreate(t *testing.T) { // TriggerTemplate tt, err := c.TriggersClient.TriggersV1alpha1().TriggerTemplates(namespace).Create(context.Background(), bldr.TriggerTemplate("my-triggertemplate", "", + bldr.TriggerTemplateMeta( + bldr.Label("tekton.dev/old-escape-quotes", "true"), + ), bldr.TriggerTemplateSpec( bldr.TriggerTemplateParam("oneparam", "", ""), bldr.TriggerTemplateParam("twoparamname", "", ""), @@ -321,10 +324,7 @@ func TestEventListenerCreate(t *testing.T) { t.Log("EventListener is ready") // Load the example pull request event data - eventBodyJSON, err := loadExamplePREventBytes() - if err != nil { - t.Fatalf("Couldn't load test data: %v", err) - } + eventBodyJSON := loadExamplePREventBytes(t) // Event body & Expected ResourceTemplates after instantiation wantPr1 := v1alpha1.PipelineResource{