Skip to content

Commit

Permalink
Drop escaping of strings in the JSON.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bigkevmcd committed Nov 16, 2020
1 parent 3fa0d8a commit b2339ed
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/eventlistener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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", "", ""),
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit b2339ed

Please sign in to comment.