Skip to content

Commit

Permalink
removed GetRepository (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
ATGardner authored May 11, 2021
1 parent a2f56a7 commit 0118a17
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 101 deletions.
21 changes: 0 additions & 21 deletions pkg/git/mocks/provider.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pkg/git/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ type (
// CreateRepository creates the repository in the remote provider and returns a
// clone url
CreateRepository(ctx context.Context, opts *CreateRepoOptions) (string, error)

GetRepository(ctx context.Context, opts *GetRepoOptions) (string, error)
}

Auth struct {
Expand Down
13 changes: 0 additions & 13 deletions pkg/git/provider_github.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,6 @@ func newGithub(opts *ProviderOptions) (Provider, error) {
return g, nil
}

func (g *github) GetRepository(ctx context.Context, opts *GetRepoOptions) (string, error) {
r, res, err := g.Repositories.Get(ctx, opts.Owner, opts.Name)
if res != nil && res.StatusCode == http.StatusNotFound {
return "", ErrRepoNotFound
}

if err != nil {
return "", err
}

return *r.CloneURL, nil
}

func (g *github) CreateRepository(ctx context.Context, opts *CreateRepoOptions) (string, error) {
authUser, res, err := g.Users.Get(ctx, "") // get authenticated user details
if err != nil {
Expand Down
65 changes: 0 additions & 65 deletions pkg/git/provider_github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,71 +11,6 @@ import (
"github.com/stretchr/testify/assert"
)

func Test_github_GetRepository(t *testing.T) {
tests := map[string]struct {
repo *gh.Repository
res *gh.Response
err error
opts *GetRepoOptions
want string
wantErr string
}{
"No repo": {
res: &gh.Response{
Response: &http.Response{
StatusCode: http.StatusNotFound,
},
},
opts: &GetRepoOptions{
Owner: "owner",
Name: "repo",
},
want: "",
wantErr: "git repository not found",
},
"Has repo": {
repo: &gh.Repository{
CloneURL: gh.String("https://github.com/owner/repo"),
},
opts: &GetRepoOptions{
Owner: "owner",
Name: "repo",
},
want: "https://github.com/owner/repo",
wantErr: "",
},
"Error getting repo": {
err: errors.New("Some error"),
opts: &GetRepoOptions{
Owner: "owner",
Name: "repo",
},
want: "",
wantErr: "Some error",
},
}

for name, tt := range tests {
t.Run(name, func(t *testing.T) {
mockRepo := new(mocks.Repositories)
ctx := context.Background()
mockRepo.On("Get", ctx, tt.opts.Owner, tt.opts.Name).Return(tt.repo, tt.res, tt.err)
g := &github{
Repositories: mockRepo,
}
got, err := g.GetRepository(ctx, tt.opts)
if tt.wantErr != "" {
assert.EqualError(t, err, tt.wantErr)
return
}

if got != tt.want {
t.Errorf("github.GetRepository() = %v, want %v", got, tt.want)
}
})
}
}

func Test_github_CreateRepository(t *testing.T) {
tests := map[string]struct {
user *gh.User
Expand Down

0 comments on commit 0118a17

Please sign in to comment.