Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions github/migrations_source_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}