(feat) add delete file for github and gitlab

pull/110/head
TP Honey 3 years ago
parent 609b30dd07
commit 1d0ee4a2d8

@ -47,7 +47,7 @@ type (
Update(ctx context.Context, repo, path string, params *ContentParams) (*Response, error)
// Delete deletes a reository file.
Delete(ctx context.Context, repo, path, ref string) (*Response, error)
Delete(ctx context.Context, repo, path string, params *ContentParams) (*Response, error)
// List returns a list of contents in a repository directory by path. It is
// up to the driver to list the directory recursively or non-recursively,

@ -67,7 +67,7 @@ func (s *contentService) Update(ctx context.Context, repo, path string, params *
return res, err
}
func (s *contentService) Delete(ctx context.Context, repo, path, ref string) (*scm.Response, error) {
func (s *contentService) Delete(ctx context.Context, repo, path string, params *scm.ContentParams) (*scm.Response, error) {
return nil, scm.ErrNotSupported
}

@ -184,7 +184,7 @@ func TestContentUpdateBadCommitID(t *testing.T) {
func TestContentDelete(t *testing.T) {
content := new(contentService)
_, err := content.Delete(context.Background(), "atlassian/atlaskit", "README", "master")
_, err := content.Delete(context.Background(), "atlassian/atlaskit", "README", &scm.ContentParams{})
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}

@ -34,7 +34,7 @@ func (s *contentService) Update(ctx context.Context, repo, path string, params *
return nil, scm.ErrNotSupported
}
func (s *contentService) Delete(ctx context.Context, repo, path, ref string) (*scm.Response, error) {
func (s *contentService) Delete(ctx context.Context, repo, path string, params *scm.ContentParams) (*scm.Response, error) {
return nil, scm.ErrNotSupported
}

@ -61,7 +61,7 @@ func TestContentUpdate(t *testing.T) {
func TestContentDelete(t *testing.T) {
client, _ := New("https://try.gitea.io")
_, err := client.Contents.Delete(context.Background(), "go-gitea/gitea", "README.md", "master")
_, err := client.Contents.Delete(context.Background(), "go-gitea/gitea", "README.md", &scm.ContentParams{})
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}

@ -70,8 +70,24 @@ func (s *contentService) Update(ctx context.Context, repo, path string, params *
return res, err
}
func (s *contentService) Delete(ctx context.Context, repo, path, ref string) (*scm.Response, error) {
return nil, scm.ErrNotSupported
func (s *contentService) Delete(ctx context.Context, repo, path string, params *scm.ContentParams) (*scm.Response, error) {
endpoint := fmt.Sprintf("repos/%s/contents/%s", repo, path)
in := &contentCreateUpdate{
Message: params.Message,
Branch: params.Branch,
// NB the sha passed to github rest api is the blob sha, not the commit sha
Sha: params.BlobID,
Committer: commitAuthor{
Name: params.Signature.Name,
Email: params.Signature.Email,
},
Author: commitAuthor{
Name: params.Signature.Name,
Email: params.Signature.Email,
},
}
res, err := s.client.do(ctx, "DELETE", endpoint, in, nil)
return res, err
}
func (s *contentService) List(ctx context.Context, repo, path, ref string, _ scm.ListOptions) ([]*scm.ContentInfo, *scm.Response, error) {

@ -40,7 +40,7 @@ func TestContentFind(t *testing.T) {
want := new(scm.Content)
raw, _ := ioutil.ReadFile("testdata/content.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -159,10 +159,39 @@ func TestContentUpdateBadBlobID(t *testing.T) {
}
func TestContentDelete(t *testing.T) {
content := new(contentService)
_, err := content.Delete(context.Background(), "octocat/hello-world", "README", "master")
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
defer gock.Off()
gock.New("https://api.github.com").
Delete("/repos/octocat/hello-world/contents/test/hello").
Reply(200).
Type("application/json").
SetHeaders(mockHeaders).
File("testdata/content_delete.json")
params := &scm.ContentParams{
Message: "a new commit message",
BlobID: "95b966ae1c166bd92f8ae7d1c313e738c731dfc3",
Signature: scm.Signature{
Name: "Monalisa Octocat",
Email: "octocat@github.com",
},
}
client := NewDefault()
res, err := client.Contents.Delete(
context.Background(),
"octocat/hello-world",
"test/hello",
params,
)
if err != nil {
t.Error(err)
return
}
if res.Status != 200 {
t.Errorf("Unexpected Results")
}
}
@ -192,7 +221,7 @@ func TestContentList(t *testing.T) {
want := []*scm.ContentInfo{}
raw, _ := ioutil.ReadFile("testdata/content_list.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -35,7 +35,7 @@ func TestGitFindCommit(t *testing.T) {
want := new(scm.Commit)
raw, _ := ioutil.ReadFile("testdata/commit.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -65,7 +65,7 @@ func TestGitFindBranch(t *testing.T) {
want := new(scm.Reference)
raw, _ := ioutil.ReadFile("testdata/branch.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -95,7 +95,7 @@ func TestGitFindTag(t *testing.T) {
want := new(scm.Reference)
raw, _ := ioutil.ReadFile("testdata/tag.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -161,7 +161,7 @@ func TestGitListCommits(t *testing.T) {
want := []*scm.Commit{}
raw, _ := ioutil.ReadFile("testdata/commits.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -195,7 +195,7 @@ func TestGitListBranches(t *testing.T) {
want := []*scm.Reference{}
raw, _ := ioutil.ReadFile("testdata/branches.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -229,7 +229,7 @@ func TestGitListTags(t *testing.T) {
want := []*scm.Reference{}
raw, _ := ioutil.ReadFile("testdata/tags.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -260,7 +260,7 @@ func TestGitListChanges(t *testing.T) {
want := []*scm.Change{}
raw, _ := ioutil.ReadFile("testdata/changes.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -290,7 +290,7 @@ func TestGitCompareChanges(t *testing.T) {
want := []*scm.Change{}
raw, _ := ioutil.ReadFile("testdata/compare.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -35,7 +35,7 @@ func TestIssueFind(t *testing.T) {
want := new(scm.Issue)
raw, _ := ioutil.ReadFile("testdata/issue.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -65,7 +65,7 @@ func TestIssueCommentFind(t *testing.T) {
want := new(scm.Comment)
raw, _ := ioutil.ReadFile("testdata/issue_comment.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -99,7 +99,7 @@ func TestIssueList(t *testing.T) {
want := []*scm.Issue{}
raw, _ := ioutil.ReadFile("testdata/issues.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -133,7 +133,7 @@ func TestIssueListComments(t *testing.T) {
want := []*scm.Comment{}
raw, _ := ioutil.ReadFile("testdata/issue_comments.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -169,7 +169,7 @@ func TestIssueCreate(t *testing.T) {
want := new(scm.Issue)
raw, _ := ioutil.ReadFile("testdata/issue.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -203,7 +203,7 @@ func TestIssueCreateComment(t *testing.T) {
want := new(scm.Comment)
raw, _ := ioutil.ReadFile("testdata/issue_comment.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -35,7 +35,7 @@ func TestOrganizationFind(t *testing.T) {
want := new(scm.Organization)
raw, _ := ioutil.ReadFile("testdata/org.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -65,7 +65,7 @@ func TestOrganizationFindMembership(t *testing.T) {
want := new(scm.Membership)
raw, _ := ioutil.ReadFile("testdata/membership.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -98,7 +98,7 @@ func TestOrganizationList(t *testing.T) {
want := []*scm.Organization{}
raw, _ := ioutil.ReadFile("testdata/orgs.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -35,7 +35,7 @@ func TestPullFind(t *testing.T) {
want := new(scm.PullRequest)
raw, _ := ioutil.ReadFile("testdata/pr.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -69,7 +69,7 @@ func TestPullList(t *testing.T) {
want := []*scm.PullRequest{}
raw, _ := ioutil.ReadFile("testdata/pulls.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -101,7 +101,7 @@ func TestPullListChanges(t *testing.T) {
want := []*scm.Change{}
raw, _ := ioutil.ReadFile("testdata/pr_files.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -179,7 +179,7 @@ func TestPullCreate(t *testing.T) {
want := new(scm.PullRequest)
raw, _ := ioutil.ReadFile("testdata/pr.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -210,7 +210,7 @@ func TestPullListCommits(t *testing.T) {
want := []*scm.Commit{}
raw, _ := ioutil.ReadFile("testdata/commits.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -34,7 +34,7 @@ func TestRepositoryFind(t *testing.T) {
want := new(scm.Repository)
raw, _ := ioutil.ReadFile("testdata/repo.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -64,7 +64,7 @@ func TestRepositoryPerms(t *testing.T) {
want := new(scm.Repository)
raw, _ := ioutil.ReadFile("testdata/repo.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want.Perm); diff != "" {
t.Errorf("Unexpected Results")
@ -118,7 +118,7 @@ func TestRepositoryList(t *testing.T) {
want := []*scm.Repository{}
raw, _ := ioutil.ReadFile("testdata/repos.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -152,7 +152,7 @@ func TestStatusList(t *testing.T) {
want := []*scm.Status{}
raw, _ := ioutil.ReadFile("testdata/statuses.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -190,7 +190,7 @@ func TestStatusCreate(t *testing.T) {
want := new(scm.Status)
raw, _ := ioutil.ReadFile("testdata/status.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -229,7 +229,7 @@ func TestDeployStatusCreate(t *testing.T) {
want := new(scm.DeployStatus)
raw, _ := ioutil.ReadFile("testdata/deployment.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -259,7 +259,7 @@ func TestRepositoryHookFind(t *testing.T) {
want := new(scm.Hook)
raw, _ := ioutil.ReadFile("testdata/hook.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -292,7 +292,7 @@ func TestRepositoryHookList(t *testing.T) {
want := []*scm.Hook{}
raw, _ := ioutil.ReadFile("testdata/hooks.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -330,7 +330,7 @@ func TestRepositoryHookCreate(t *testing.T) {
want := new(scm.Hook)
raw, _ := ioutil.ReadFile("testdata/hook.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -367,7 +367,7 @@ func TestRepositoryHookUpdate(t *testing.T) {
want := new(scm.Hook)
raw, _ := ioutil.ReadFile("testdata/hook.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -34,7 +34,7 @@ func TestReviewFind(t *testing.T) {
want := new(scm.Review)
raw, _ := ioutil.ReadFile("testdata/pr_comment.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -67,7 +67,7 @@ func TestReviewList(t *testing.T) {
want := []*scm.Review{}
raw, _ := ioutil.ReadFile("testdata/pr_comments.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -105,7 +105,7 @@ func TestReviewCreate(t *testing.T) {
want := new(scm.Review)
raw, _ := ioutil.ReadFile("testdata/pr_comment.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -0,0 +1,37 @@
{
"content": null,
"commit": {
"sha": "7638417db6d59f3c431d3e1f261cc637155684cd",
"node_id": "MDY6Q29tbWl0NzYzODQxN2RiNmQ1OWYzYzQzMWQzZTFmMjYxY2M2MzcxNTU2ODRjZA==",
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/7638417db6d59f3c431d3e1f261cc637155684cd",
"html_url": "https://github.com/octocat/Hello-World/git/commit/7638417db6d59f3c431d3e1f261cc637155684cd",
"author": {
"date": "2014-11-07T22:01:45Z",
"name": "Monalisa Octocat",
"email": "octocat@github.com"
},
"committer": {
"date": "2014-11-07T22:01:45Z",
"name": "Monalisa Octocat",
"email": "octocat@github.com"
},
"message": "my commit message",
"tree": {
"url": "https://api.github.com/repos/octocat/Hello-World/git/trees/691272480426f78a0138979dd3ce63b77f706feb",
"sha": "691272480426f78a0138979dd3ce63b77f706feb"
},
"parents": [
{
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/1acc419d4d6a9ce985db7be48c6349a0475975b5",
"html_url": "https://github.com/octocat/Hello-World/git/commit/1acc419d4d6a9ce985db7be48c6349a0475975b5",
"sha": "1acc419d4d6a9ce985db7be48c6349a0475975b5"
}
],
"verification": {
"verified": false,
"reason": "unsigned",
"signature": null,
"payload": null
}
}
}

@ -39,7 +39,7 @@ func TestUserFind(t *testing.T) {
want := new(scm.User)
raw, _ := ioutil.ReadFile("testdata/user.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -71,12 +71,12 @@ func TestUserLoginFind(t *testing.T) {
want := new(scm.User)
raw, _ := ioutil.ReadFile("testdata/user.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
t.Log(diff)
json.NewEncoder(os.Stdout).Encode(got)
_ = json.NewEncoder(os.Stdout).Encode(got)
}
t.Run("Request", testRequest(res))

@ -223,7 +223,7 @@ func TestWebhooks(t *testing.T) {
t.Log(diff)
// debug only. remove once implemented
json.NewEncoder(os.Stdout).Encode(o)
_ = json.NewEncoder(os.Stdout).Encode(o)
}
switch event := o.(type) {

@ -69,8 +69,18 @@ func (s *contentService) Update(ctx context.Context, repo, path string, params *
return res, err
}
func (s *contentService) Delete(ctx context.Context, repo, path, ref string) (*scm.Response, error) {
return nil, scm.ErrNotSupported
func (s *contentService) Delete(ctx context.Context, repo, path string, params *scm.ContentParams) (*scm.Response, error) {
endpoint := fmt.Sprintf("api/v4/projects/%s/repository/files/%s", encode(repo), encodePath(path))
in := &createUpdateContent{
Branch: params.Branch,
CommitMessage: params.Message,
Encoding: "base64",
AuthorName: params.Signature.Name,
AuthorEmail: params.Signature.Email,
LastCommitID: params.Sha,
}
res, err := s.client.do(ctx, "DELETE", endpoint, in, nil)
return res, err
}
func (s *contentService) List(ctx context.Context, repo, path, ref string, opts scm.ListOptions) ([]*scm.ContentInfo, *scm.Response, error) {

@ -142,10 +142,31 @@ func TestContentUpdateBadCommitID(t *testing.T) {
}
func TestContentDelete(t *testing.T) {
content := new(contentService)
_, err := content.Delete(context.Background(), "octocat/hello-world", "README", "master")
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
defer gock.Off()
gock.New("https://gitlab.com").
Delete("/api/v4/projects/diaspora/diaspora/repository/files/app/project.rb").
Reply(200).
Type("application/json").
SetHeaders(mockHeaders)
client := NewDefault()
params := &scm.ContentParams{
Message: "update file",
Signature: scm.Signature{
Name: "Firstname Lastname",
Email: "kubesphere@example.com",
},
}
res, err := client.Contents.Delete(context.Background(), "diaspora/diaspora", "app/project.rb", params)
if err != nil {
t.Error(err)
return
}
if res.Status != 200 {
t.Errorf("Unexpected Results")
}
}

@ -34,7 +34,7 @@ func (s *contentService) Update(ctx context.Context, repo, path string, params *
return nil, scm.ErrNotSupported
}
func (s *contentService) Delete(ctx context.Context, repo, path, ref string) (*scm.Response, error) {
func (s *contentService) Delete(ctx context.Context, repo, path string, params *scm.ContentParams) (*scm.Response, error) {
return nil, scm.ErrNotSupported
}

@ -58,7 +58,7 @@ func TestContentUpdate(t *testing.T) {
func TestContentDelete(t *testing.T) {
client, _ := New("https://try.gogs.io")
_, err := client.Contents.Delete(context.Background(), "gogits/gogs", "README.md", "master")
_, err := client.Contents.Delete(context.Background(), "gogits/gogs", "README.md", &scm.ContentParams{})
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}

@ -35,7 +35,7 @@ func (s *contentService) Update(ctx context.Context, repo, path string, params *
return nil, scm.ErrNotSupported
}
func (s *contentService) Delete(ctx context.Context, repo, path, ref string) (*scm.Response, error) {
func (s *contentService) Delete(ctx context.Context, repo, path string, params *scm.ContentParams) (*scm.Response, error) {
return nil, scm.ErrNotSupported
}

@ -34,7 +34,7 @@ func TestContentFind(t *testing.T) {
want := new(scm.Content)
raw, _ := ioutil.ReadFile("testdata/content.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -60,7 +60,7 @@ func TestContentUpdate(t *testing.T) {
func TestContentDelete(t *testing.T) {
content := new(contentService)
_, err := content.Delete(context.Background(), "atlassian/atlaskit", "README", "master")
_, err := content.Delete(context.Background(), "atlassian/atlaskit", "README", &scm.ContentParams{})
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
@ -90,7 +90,7 @@ func TestContentList(t *testing.T) {
want := []*scm.ContentInfo{}
raw, _ := ioutil.ReadFile("testdata/content_list.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -33,7 +33,7 @@ func TestGitFindCommit(t *testing.T) {
want := new(scm.Commit)
raw, _ := ioutil.ReadFile("testdata/commit.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -59,7 +59,7 @@ func TestGitFindBranch(t *testing.T) {
want := new(scm.Reference)
raw, _ := ioutil.ReadFile("testdata/branch.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -85,7 +85,7 @@ func TestGitFindTag(t *testing.T) {
want := new(scm.Reference)
raw, _ := ioutil.ReadFile("testdata/tag.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -110,7 +110,7 @@ func TestGitListCommits(t *testing.T) {
want := []*scm.Commit{}
raw, _ := ioutil.ReadFile("testdata/commits.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -136,7 +136,7 @@ func TestGitListBranches(t *testing.T) {
want := []*scm.Reference{}
raw, _ := ioutil.ReadFile("testdata/branches.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -164,7 +164,7 @@ func TestGitListTags(t *testing.T) {
want := []*scm.Reference{}
raw, _ := ioutil.ReadFile("testdata/tags.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -192,7 +192,7 @@ func TestGitListChanges(t *testing.T) {
want := []*scm.Change{}
raw, _ := ioutil.ReadFile("testdata/changes.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -220,7 +220,7 @@ func TestGitCompareChanges(t *testing.T) {
want := []*scm.Change{}
raw, _ := ioutil.ReadFile("testdata/compare.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -33,7 +33,7 @@ func TestPullFind(t *testing.T) {
want := new(scm.PullRequest)
raw, _ := ioutil.ReadFile("testdata/pr.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -58,7 +58,7 @@ func TestPullFindComment(t *testing.T) {
want := new(scm.Comment)
raw, _ := ioutil.ReadFile("testdata/pr_comment.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -83,7 +83,7 @@ func TestPullList(t *testing.T) {
want := []*scm.PullRequest{}
raw, _ := ioutil.ReadFile("testdata/prs.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -110,7 +110,7 @@ func TestPullListChanges(t *testing.T) {
want := []*scm.Change{}
raw, _ := ioutil.ReadFile("testdata/pr_change.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -174,7 +174,7 @@ func TestPullCreate(t *testing.T) {
want := new(scm.PullRequest)
raw, _ := ioutil.ReadFile("testdata/pr.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -201,7 +201,7 @@ func TestPullCreateComment(t *testing.T) {
want := new(scm.Comment)
raw, _ := ioutil.ReadFile("testdata/pr_comment.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -226,7 +226,7 @@ func TestPullListCommits(t *testing.T) {
want := []*scm.Commit{}
raw, _ := ioutil.ReadFile("testdata/commits.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -33,7 +33,7 @@ func TestRepositoryFind(t *testing.T) {
want := new(scm.Repository)
raw, _ := ioutil.ReadFile("testdata/repo.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -237,7 +237,7 @@ func TestRepositoryList(t *testing.T) {
want := []*scm.Repository{}
raw, _ := ioutil.ReadFile("testdata/repos.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -293,7 +293,7 @@ func TestRepositoryHookFind(t *testing.T) {
want := new(scm.Hook)
raw, _ := ioutil.ReadFile("testdata/webhook.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -320,7 +320,7 @@ func TestRepositoryHookList(t *testing.T) {
want := []*scm.Hook{}
raw, _ := ioutil.ReadFile("testdata/webhooks.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -357,7 +357,7 @@ func TestRepositoryHookCreate(t *testing.T) {
want := new(scm.Hook)
raw, _ := ioutil.ReadFile("testdata/webhook.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -394,7 +394,7 @@ func TestRepositoryHookUpdate(t *testing.T) {
want := new(scm.Hook)
raw, _ := ioutil.ReadFile("testdata/webhook.json.golden")
json.Unmarshal(raw, want)
_ = json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -20,7 +20,7 @@ type userService struct {
}
func (s *userService) Find(ctx context.Context) (*scm.User, *scm.Response, error) {
path := fmt.Sprintf("plugins/servlet/applinks/whoami")
path := "plugins/servlet/applinks/whoami"
out := new(bytes.Buffer)
res, err := s.client.do(ctx, "GET", path, nil, out)
if err != nil {

@ -39,7 +39,7 @@ func TestUserFind(t *testing.T) {
want := new(scm.User)
raw, _ := ioutil.ReadFile("testdata/user.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -82,7 +82,7 @@ func TestUserLoginFind(t *testing.T) {
want := new(scm.User)
raw, _ := ioutil.ReadFile("testdata/user.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
@ -117,7 +117,7 @@ func TestUserLoginFind_ViaSearch(t *testing.T) {
want := new(scm.User)
raw, _ := ioutil.ReadFile("testdata/user_search.json.golden")
json.Unmarshal(raw, &want)
_ = json.Unmarshal(raw, &want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")

@ -144,7 +144,7 @@ func TestWebhooks(t *testing.T) {
t.Log(diff)
// debug only. remove once implemented
json.NewEncoder(os.Stdout).Encode(o)
_ = json.NewEncoder(os.Stdout).Encode(o)
}
switch event := o.(type) {

Loading…
Cancel
Save