From d04dafbf66ff289f05378c48cb8bd308e6097707 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Mon, 12 Jul 2021 23:54:09 +0530 Subject: [PATCH 1/2] Resources Covered : - ServiceHook - CodeOfConduct - markdownRequest --- github/misc_test.go | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/github/misc_test.go b/github/misc_test.go index 4e38b4c4832..fc6e5e9663b 100644 --- a/github/misc_test.go +++ b/github/misc_test.go @@ -348,3 +348,68 @@ func TestListServiceHooks(t *testing.T) { return resp, err }) } + +func TestMarkdownRequest_marshal(t *testing.T) { + testJSONMarshal(t, &markdownRequest{}, "{}") + + a := &markdownRequest{ + Text: String("txt"), + Mode: String("mode"), + Context: String("ctx"), + } + + want := `{ + "text": "txt", + "mode": "mode", + "context": "ctx" + }` + + testJSONMarshal(t, a, want) +} + +func TestCodeOfConduct_marshal(t *testing.T) { + testJSONMarshal(t, &CodeOfConduct{}, "{}") + + a := &CodeOfConduct{ + Name: String("name"), + Key: String("key"), + URL: String("url"), + Body: String("body"), + } + + want := `{ + "name": "name", + "key": "key", + "url": "url", + "body": "body" + }` + + testJSONMarshal(t, a, want) +} + +func TestServiceHook_marshal(t *testing.T) { + testJSONMarshal(t, &ServiceHook{}, "{}") + + a := &ServiceHook{ + Name: String("name"), + Events: []string{"e"}, + SupportedEvents: []string{"se"}, + Schema: [][]string{{"g"}}, + } + want := `{ + "name": "name", + "events": [ + "e" + ], + "supported_events": [ + "se" + ], + "schema": [ + [ + "g" + ] + ] + }` + + testJSONMarshal(t, a, want) +} From 7f08b60400dd07267b6275b706670902edb15883 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Tue, 13 Jul 2021 01:12:00 +0530 Subject: [PATCH 2/2] fixed naming convention --- github/misc_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/misc_test.go b/github/misc_test.go index fc6e5e9663b..8b15fd4631d 100644 --- a/github/misc_test.go +++ b/github/misc_test.go @@ -177,7 +177,7 @@ func TestGetCodeOfConduct(t *testing.T) { }) } -func TestAPIMeta_marshal(t *testing.T) { +func TestAPIMeta_Marshal(t *testing.T) { testJSONMarshal(t, &APIMeta{}, "{}") a := &APIMeta{ @@ -349,7 +349,7 @@ func TestListServiceHooks(t *testing.T) { }) } -func TestMarkdownRequest_marshal(t *testing.T) { +func TestMarkdownRequest_Marshal(t *testing.T) { testJSONMarshal(t, &markdownRequest{}, "{}") a := &markdownRequest{ @@ -367,7 +367,7 @@ func TestMarkdownRequest_marshal(t *testing.T) { testJSONMarshal(t, a, want) } -func TestCodeOfConduct_marshal(t *testing.T) { +func TestCodeOfConduct_Marshal(t *testing.T) { testJSONMarshal(t, &CodeOfConduct{}, "{}") a := &CodeOfConduct{ @@ -387,7 +387,7 @@ func TestCodeOfConduct_marshal(t *testing.T) { testJSONMarshal(t, a, want) } -func TestServiceHook_marshal(t *testing.T) { +func TestServiceHook_Marshal(t *testing.T) { testJSONMarshal(t, &ServiceHook{}, "{}") a := &ServiceHook{