diff --git a/github/repos_test.go b/github/repos_test.go index ec32b5d578..0fdc4b27d9 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -3002,3 +3002,84 @@ func TestAuthorizedActorsOnly_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestDispatchRequestOptions_Marshal(t *testing.T) { + testJSONMarshal(t, &DispatchRequestOptions{}, "{}") + + cp := json.RawMessage(`{"testKey":"testValue"}`) + u := &DispatchRequestOptions{ + EventType: "test_event_type", + ClientPayload: &cp, + } + + want := `{ + "event_type": "test_event_type", + "client_payload": { + "testKey": "testValue" + } + }` + + testJSONMarshal(t, u, want) +} + +func TestTransferRequest_Marshal(t *testing.T) { + testJSONMarshal(t, &TransferRequest{}, "{}") + + u := &TransferRequest{ + NewOwner: "testOwner", + TeamID: []int64{1, 2}, + } + + want := `{ + "new_owner": "testOwner", + "team_ids": [1,2] + }` + + testJSONMarshal(t, u, want) +} + +func TestSignaturesProtectedBranch_Marshal(t *testing.T) { + testJSONMarshal(t, &SignaturesProtectedBranch{}, "{}") + + u := &SignaturesProtectedBranch{ + URL: String("https://www.testURL.in"), + Enabled: Bool(false), + } + + want := `{ + "url": "https://www.testURL.in", + "enabled": false + }` + + testJSONMarshal(t, u, want) + + u2 := &SignaturesProtectedBranch{ + URL: String("testURL"), + Enabled: Bool(true), + } + + want2 := `{ + "url": "testURL", + "enabled": true + }` + + testJSONMarshal(t, u2, want2) +} + +func TestDismissalRestrictionsRequest_Marshal(t *testing.T) { + testJSONMarshal(t, &DismissalRestrictionsRequest{}, "{}") + + u := &DismissalRestrictionsRequest{ + Users: &[]string{"user1", "user2"}, + Teams: &[]string{"team1", "team2"}, + Apps: &[]string{"app1", "app2"}, + } + + want := `{ + "users": ["user1","user2"], + "teams": ["team1","team2"], + "apps": ["app1","app2"] + }` + + testJSONMarshal(t, u, want) +}