From d0291df15c6291f0dd3c4e5bf43215e54a12e91c Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Mon, 12 Jul 2021 23:34:25 +0530 Subject: [PATCH] Resources Covered : - startMigration - Migration --- github/migrations_test.go | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/github/migrations_test.go b/github/migrations_test.go index 7e31fcbaa69..4a5c0fc6c06 100644 --- a/github/migrations_test.go +++ b/github/migrations_test.go @@ -251,3 +251,57 @@ var wantMigration = &Migration{ }, }, } + +func TestMigration_Marshal(t *testing.T) { + testJSONMarshal(t, &Migration{}, "{}") + + u := &Migration{ + ID: Int64(1), + GUID: String("guid"), + State: String("state"), + LockRepositories: Bool(false), + ExcludeAttachments: Bool(false), + URL: String("url"), + CreatedAt: String("ca"), + UpdatedAt: String("ua"), + Repositories: []*Repository{{ID: Int64(1)}}, + } + + want := `{ + "id": 1, + "guid": "guid", + "state": "state", + "lock_repositories": false, + "exclude_attachments": false, + "url": "url", + "created_at": "ca", + "updated_at": "ua", + "repositories": [ + { + "id": 1 + } + ] + }` + + testJSONMarshal(t, u, want) +} + +func TestStartMigration_Marshal(t *testing.T) { + testJSONMarshal(t, &startMigration{}, "{}") + + u := &startMigration{ + Repositories: []string{"r"}, + LockRepositories: Bool(false), + ExcludeAttachments: Bool(false), + } + + want := `{ + "repositories": [ + "r" + ], + "lock_repositories": false, + "exclude_attachments": false + }` + + testJSONMarshal(t, u, want) +}