From 9ca3e1a0b367201701b05b4499125a5e84c39648 Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Mon, 12 Jul 2021 13:22:06 +0530 Subject: [PATCH] Resources Covered : - createCommit - CommitAuthor - SignatureVerification --- github/git_commits_test.go | 86 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/github/git_commits_test.go b/github/git_commits_test.go index 1e313cb56fe..c73ff09a01c 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -583,3 +583,89 @@ BqTKXNkzAvV+CKOyaUILSBBWdef+cxVrDCJuuC3894x3G1FjJycOy0m9PArvGtSG g7/0Bp9oLXwiHzFoUMDvx+WlPnPHQNcufmQXUNdZvg+Ad4/unEU81EGDBDz3Eg== =VFSn -----END PGP PRIVATE KEY BLOCK-----` + +func TestSignatureVerification_Marshal(t *testing.T) { + testJSONMarshal(t, &SignatureVerification{}, "{}") + + u := &SignatureVerification{ + Verified: Bool(true), + Reason: String("reason"), + Signature: String("sign"), + Payload: String("payload"), + } + + want := `{ + "verified": true, + "reason": "reason", + "signature": "sign", + "payload": "payload" + }` + + testJSONMarshal(t, u, want) +} + +func TestCommitAuthor_Marshal(t *testing.T) { + testJSONMarshal(t, &CommitAuthor{}, "{}") + + u := &CommitAuthor{ + Date: &referenceTime, + Name: String("name"), + Email: String("email"), + Login: String("login"), + } + + want := `{ + "date": ` + referenceTimeStr + `, + "name": "name", + "email": "email", + "username": "login" + }` + + testJSONMarshal(t, u, want) +} + +func TestCreateCommit_Marshal(t *testing.T) { + testJSONMarshal(t, &createCommit{}, "{}") + + u := &createCommit{ + Author: &CommitAuthor{ + Date: &referenceTime, + Name: String("name"), + Email: String("email"), + Login: String("login"), + }, + Committer: &CommitAuthor{ + Date: &referenceTime, + Name: String("name"), + Email: String("email"), + Login: String("login"), + }, + Message: String("message"), + Tree: String("tree"), + Parents: []string{"p"}, + Signature: String("sign"), + } + + want := `{ + "author": { + "date": ` + referenceTimeStr + `, + "name": "name", + "email": "email", + "username": "login" + }, + "committer": { + "date": ` + referenceTimeStr + `, + "name": "name", + "email": "email", + "username": "login" + }, + "message": "message", + "tree": "tree", + "parents": [ + "p" + ], + "signature": "sign" + }` + + testJSONMarshal(t, u, want) +}