From 1810eac0a35bba67072a3c072bdb73cc9e4da06d Mon Sep 17 00:00:00 2001 From: sagar23sj Date: Mon, 12 Jul 2021 20:17:45 +0530 Subject: [PATCH] Resources Covered : - Import - SourceImportAuthor - LargeFile --- github/migrations_source_import_test.go | 108 ++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/github/migrations_source_import_test.go b/github/migrations_source_import_test.go index 71ecbdc9d2f..bcb49de1c90 100644 --- a/github/migrations_source_import_test.go +++ b/github/migrations_source_import_test.go @@ -333,3 +333,111 @@ func TestMigrationService_CancelImport(t *testing.T) { return client.Migrations.CancelImport(ctx, "o", "r") }) } + +func TestLargeFile_Marshal(t *testing.T) { + testJSONMarshal(t, &LargeFile{}, "{}") + + u := &LargeFile{ + RefName: String("rn"), + Path: String("p"), + OID: String("oid"), + Size: Int(1), + } + + want := `{ + "ref_name": "rn", + "path": "p", + "oid": "oid", + "size": 1 + }` + + testJSONMarshal(t, u, want) +} + +func TestSourceImportAuthor_Marshal(t *testing.T) { + testJSONMarshal(t, &SourceImportAuthor{}, "{}") + + u := &SourceImportAuthor{ + ID: Int64(1), + RemoteID: String("rid"), + RemoteName: String("rn"), + Email: String("e"), + Name: String("n"), + URL: String("url"), + ImportURL: String("iurl"), + } + + want := `{ + "id": 1, + "remote_id": "rid", + "remote_name": "rn", + "email": "e", + "name": "n", + "url": "url", + "import_url": "iurl" + }` + + testJSONMarshal(t, u, want) +} + +func TestImport_Marshal(t *testing.T) { + testJSONMarshal(t, &Import{}, "{}") + + u := &Import{ + VCSURL: String("vcsurl"), + VCS: String("vcs"), + VCSUsername: String("vcsusr"), + VCSPassword: String("vcspass"), + TFVCProject: String("tfvcp"), + UseLFS: String("uselfs"), + HasLargeFiles: Bool(false), + LargeFilesSize: Int(1), + LargeFilesCount: Int(1), + Status: String("status"), + CommitCount: Int(1), + StatusText: String("statustxt"), + AuthorsCount: Int(1), + Percent: Int(1), + PushPercent: Int(1), + URL: String("url"), + HTMLURL: String("hurl"), + AuthorsURL: String("aurl"), + RepositoryURL: String("rurl"), + Message: String("msg"), + FailedStep: String("fs"), + HumanName: String("hn"), + ProjectChoices: []*Import{{VCSURL: String("vcsurl")}}, + } + + want := `{ + "vcs_url": "vcsurl", + "vcs": "vcs", + "vcs_username": "vcsusr", + "vcs_password": "vcspass", + "tfvc_project": "tfvcp", + "use_lfs": "uselfs", + "has_large_files": false, + "large_files_size": 1, + "large_files_count": 1, + "status": "status", + "commit_count": 1, + "status_text": "statustxt", + "authors_count": 1, + "percent": 1, + "push_percent": 1, + "url": "url", + "html_url": "hurl", + "authors_url": "aurl", + "repository_url": "rurl", + "message": "msg", + "failed_step": "fs", + "human_name": "hn", + "project_choices": [ + { + "vcs_url": "vcsurl" + } + ] + }` + + testJSONMarshal(t, u, want) +}