Skip to content

Commit

Permalink
chore(tests) Use assert.NoError across project
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Leclercq committed Jun 17, 2016
1 parent 1c3341b commit 8d80c87
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func TestHook(t *testing.T) {
ts, gitlab := Stub("stubs/hooks/show.json")
hook, err := gitlab.ProjectHook("1", "2")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.IsType(t, new(Hook), hook)
assert.Equal(t, hook.Url, "http://example.com/hook")
defer ts.Close()
Expand All @@ -20,7 +20,7 @@ func TestParsePushHook(t *testing.T) {
stub, _ := ioutil.ReadFile("stubs/hooks/push.json")
p, err := ParseHook([]byte(stub))

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.IsType(t, new(HookPayload), p)
assert.Equal(t, p.After, "da1560886d4f094c3e6c9ef40349f7d38b5d27d7")
assert.Equal(t, p.Repository.URL, "git@localhost:diaspora.git")
Expand All @@ -35,7 +35,7 @@ func TestParseIssueHook(t *testing.T) {
stub, _ := ioutil.ReadFile("stubs/hooks/issue.json")
p, err := ParseHook([]byte(stub))

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, p.ObjectKind, "issue")
assert.Equal(t, p.ObjectAttributes.Id, 301)
}
Expand All @@ -44,7 +44,7 @@ func TestParseMergeRequestHook(t *testing.T) {
stub, _ := ioutil.ReadFile("stubs/hooks/merge_request.json")
p, err := ParseHook([]byte(stub))

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, p.ObjectKind, "merge_request")
assert.Equal(t, p.ObjectAttributes.TargetBranch, "master")
assert.Equal(t, p.ObjectAttributes.SourceProjectId, p.ObjectAttributes.TargetProjectId)
Expand Down
2 changes: 1 addition & 1 deletion issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestAddIssue(t *testing.T) {
}
issue, err := gitlab.AddIssue("1", req)

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, issue.Id, 1)
assert.Equal(t, issue.IId, 1)
assert.Equal(t, issue.ProjectId, 1)
Expand Down
16 changes: 8 additions & 8 deletions merge_requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func TestProjectMergeRequests(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/index.json")
mrs, err := gitlab.ProjectMergeRequests("3", nil)

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(mrs), 1)
defer ts.Close()
}
Expand All @@ -19,7 +19,7 @@ func TestProjectMergeRequest(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/show.json")
mr, err := gitlab.ProjectMergeRequest("3", "1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, mr.TargetBranch, "master")
assert.Equal(t, mr.MergeStatus, "can_be_merged")
assert.Equal(t, mr.SourceProjectID, 2)
Expand All @@ -31,7 +31,7 @@ func TestProjectMergeRequestCommits(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/commits.json")
commits, err := gitlab.ProjectMergeRequestCommits("3", "1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(commits), 2)
defer ts.Close()
}
Expand All @@ -40,7 +40,7 @@ func TestProjectMergeRequestChanges(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/changes.json")
mr, err := gitlab.ProjectMergeRequestChanges("3", "1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(mr.Changes), 1)
defer ts.Close()
}
Expand All @@ -52,7 +52,7 @@ func TestAddMergeRequest(t *testing.T) {
}
_, err := gitlab.AddMergeRequest(&req)

assert.Equal(t, err, nil)
assert.NoError(t, err)
defer ts.Close()
}

Expand All @@ -64,21 +64,21 @@ func TestEditMergeRequest(t *testing.T) {
}
err := gitlab.EditMergeRequest(&req)

assert.Equal(t, err, nil)
assert.NoError(t, err)
defer ts.Close()
}

func TestProjectMergeRequestAccept(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/show.json")
req := AcceptMergeRequestRequest{}
_, err := gitlab.ProjectMergeRequestAccept("3", "1", &req)
assert.Equal(t, err, nil)
assert.NoError(t, err)
defer ts.Close()
}

func TestProjectMergeRequestCancelMerge(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/show.json")
_, err := gitlab.ProjectMergeRequestCancelMerge("3", "1")
assert.Equal(t, err, nil)
assert.NoError(t, err)
defer ts.Close()
}
10 changes: 5 additions & 5 deletions projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func TestProjects(t *testing.T) {
ts, gitlab := Stub("stubs/projects/index.json")
projects, err := gitlab.Projects()

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(projects), 2)
defer ts.Close()
}
Expand All @@ -18,7 +18,7 @@ func TestProject(t *testing.T) {
ts, gitlab := Stub("stubs/projects/show.json")
project, err := gitlab.Project("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.IsType(t, new(Project), project)
assert.Equal(t, project.SshRepoUrl, "[email protected]:diaspora/diaspora-project-site.git")
assert.Equal(t, project.HttpRepoUrl, "http://example.com/diaspora/diaspora-project-site.git")
Expand All @@ -30,7 +30,7 @@ func TestProjectBranches(t *testing.T) {
ts, gitlab := Stub("stubs/projects/branches/index.json")
branches, err := gitlab.ProjectBranches("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(branches), 2)
defer ts.Close()
}
Expand All @@ -41,7 +41,7 @@ func TestRemoveProject(t *testing.T) {

result, err := gitlab.RemoveProject("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, result, true)
}

Expand All @@ -50,7 +50,7 @@ func TestListVariables(t *testing.T) {

variables, err := gitlab.ProjectVariables("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(variables), 2)
defer ts.Close()
}
Expand Down
12 changes: 6 additions & 6 deletions public_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func TestGetUserKeys(t *testing.T) {
ts, gitlab := Stub("stubs/public_keys/index.json")
keys, err := gitlab.UserKeys()

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(keys), 2)
defer ts.Close()
}
Expand All @@ -18,7 +18,7 @@ func TestListKeys(t *testing.T) {
ts, gitlab := Stub("stubs/public_keys/index.json")
keys, err := gitlab.ListKeys("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(keys), 2)
defer ts.Close()
}
Expand All @@ -27,7 +27,7 @@ func TestGetUserKey(t *testing.T) {
ts, gitlab := Stub("stubs/public_keys/show.json")
key, err := gitlab.UserKey("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.IsType(t, new(PublicKey), key)
assert.Equal(t, key.Title, "Public key")
assert.Equal(t, key.Key, "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=")
Expand All @@ -38,22 +38,22 @@ func TestAddKey(t *testing.T) {
ts, gitlab := Stub("")
err := gitlab.AddKey("Public key", "stubbed key")

assert.Equal(t, err, nil)
assert.NoError(t, err)
defer ts.Close()
}

func TestAddUserKey(t *testing.T) {
ts, gitlab := Stub("")
err := gitlab.AddUserKey("1", "Public key", "stubbed key")

assert.Equal(t, err, nil)
assert.NoError(t, err)
defer ts.Close()
}

func TestDeleteKey(t *testing.T) {
ts, gitlab := Stub("")
err := gitlab.DeleteKey("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
defer ts.Close()
}
10 changes: 5 additions & 5 deletions repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func TestRepoBranches(t *testing.T) {
ts, gitlab := Stub("stubs/branches/index.json")
branches, err := gitlab.RepoBranches("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(branches), 1)
defer ts.Close()
}
Expand All @@ -18,7 +18,7 @@ func TestRepoBranch(t *testing.T) {
ts, gitlab := Stub("stubs/branches/show.json")
branch, err := gitlab.RepoBranch("1", "master")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.IsType(t, new(Branch), branch)
assert.Equal(t, branch.Name, "master")
defer ts.Close()
Expand All @@ -28,7 +28,7 @@ func TestRepoTags(t *testing.T) {
ts, gitlab := Stub("stubs/tags/index.json")
tags, err := gitlab.RepoTags("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(tags), 1)
defer ts.Close()
}
Expand All @@ -37,7 +37,7 @@ func TestRepoCommits(t *testing.T) {
ts, gitlab := Stub("stubs/commits/index.json")
commits, err := gitlab.RepoCommits("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(commits), 2)
defer ts.Close()
}
Expand All @@ -46,7 +46,7 @@ func TestRepoTree(t *testing.T) {
ts, gitlab := Stub("stubs/trees/show.json")
tree, err := gitlab.RepoTree("1", "path", "ref_name")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(tree), 6)
defer ts.Close()
}
8 changes: 4 additions & 4 deletions users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func TestUsers(t *testing.T) {
ts, gitlab := Stub("stubs/users/index.json")
users, err := gitlab.Users(0, 0)

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, len(users), 2)
defer ts.Close()
}
Expand All @@ -18,7 +18,7 @@ func TestUser(t *testing.T) {
ts, gitlab := Stub("stubs/users/show.json")
user, err := gitlab.User("plouc")

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.IsType(t, new(User), user)
assert.Equal(t, user.Id, 6)
assert.Equal(t, user.Username, "plouc")
Expand All @@ -39,15 +39,15 @@ func TestDeleteUser(t *testing.T) {
ts, gitlab := Stub("")
err := gitlab.DeleteUser("1")

assert.Equal(t, err, nil)
assert.NoError(t, err)
defer ts.Close()
}

func TestCurrentUser(t *testing.T) {
ts, gitlab := Stub("stubs/users/current.json")
user, err := gitlab.CurrentUser()

assert.Equal(t, err, nil)
assert.NoError(t, err)
assert.Equal(t, user.Username, "john_smith")
defer ts.Close()
}

0 comments on commit 8d80c87

Please sign in to comment.