Skip to content

Commit cb4df26

Browse files
authored
Add tests for resource JSON marshaling (#2536)
1 parent f659408 commit cb4df26

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

github/repos_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,3 +3083,47 @@ func TestDismissalRestrictionsRequest_Marshal(t *testing.T) {
30833083

30843084
testJSONMarshal(t, u, want)
30853085
}
3086+
3087+
func TestAdminEnforcement_Marshal(t *testing.T) {
3088+
testJSONMarshal(t, &AdminEnforcement{}, "{}")
3089+
3090+
u := &AdminEnforcement{
3091+
URL: String("https://www.test-url.in"),
3092+
Enabled: false,
3093+
}
3094+
3095+
want := `{
3096+
"url": "https://www.test-url.in",
3097+
"enabled": false
3098+
}`
3099+
3100+
testJSONMarshal(t, u, want)
3101+
}
3102+
3103+
func TestPullRequestReviewsEnforcementUpdate_Marshal(t *testing.T) {
3104+
testJSONMarshal(t, &PullRequestReviewsEnforcementUpdate{}, "{}")
3105+
3106+
u := &PullRequestReviewsEnforcementUpdate{
3107+
BypassPullRequestAllowancesRequest: &BypassPullRequestAllowancesRequest{
3108+
Users: []string{"user1", "user2"},
3109+
Teams: []string{"team1", "team2"},
3110+
Apps: []string{"app1", "app2"},
3111+
},
3112+
DismissStaleReviews: Bool(false),
3113+
RequireCodeOwnerReviews: Bool(true),
3114+
RequiredApprovingReviewCount: 2,
3115+
}
3116+
3117+
want := `{
3118+
"bypass_pull_request_allowances": {
3119+
"users": ["user1","user2"],
3120+
"teams": ["team1","team2"],
3121+
"apps": ["app1","app2"]
3122+
},
3123+
"dismiss_stale_reviews": false,
3124+
"require_code_owner_reviews": true,
3125+
"required_approving_review_count": 2
3126+
}`
3127+
3128+
testJSONMarshal(t, u, want)
3129+
}

0 commit comments

Comments
 (0)