Skip to content

Commit af0cd11

Browse files
committed
Add more coverage
1 parent f6e300b commit af0cd11

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

installer.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"errors"
66
"fmt"
77
"net/http"
8-
"net/url"
98
"path/filepath"
109
"sync"
1110

@@ -50,8 +49,6 @@ type Installer struct {
5049
fs afero.Fs
5150
service RepositoryService
5251

53-
baseURL *url.URL
54-
5552
mu sync.Mutex
5653
}
5754

@@ -205,22 +202,12 @@ func NewInstaller(fs afero.Fs, options ...Option) *Installer {
205202
}
206203

207204
if i.service == nil {
208-
c := github.NewClient(nil)
209-
c.BaseURL = i.baseURL
210-
211-
i.service = c.Repositories
205+
i.service = github.NewClient(nil).Repositories
212206
}
213207

214208
return i
215209
}
216210

217-
// WithBaseURL sets the base url for github client.
218-
func WithBaseURL(url *url.URL) Option {
219-
return func(i *Installer) {
220-
i.baseURL = url
221-
}
222-
}
223-
224211
// WithService sets the repository service.
225212
func WithService(service RepositoryService) Option {
226213
return func(i *Installer) {

installer_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ func TestInstaller_Install(t *testing.T) {
105105
}),
106106
expectedError: "could not load plugin metadata: EOF",
107107
},
108+
{
109+
scenario: "could not find artifact (no artifact)",
110+
source: "github.com/owner/my-plugin@v1.4.2",
111+
mockService: service.MockRepositoryService(func(s *service.RepositoryService) {
112+
s.On("GetReleaseByTag", mock.Anything, "owner", "my-plugin", "v1.4.2").
113+
Return(newRelease("v1.4.2"), nil, nil)
114+
115+
s.On("DownloadContents", mock.Anything, "owner", "my-plugin", ".plugin.registry.yaml",
116+
&goGitHub.RepositoryContentGetOptions{Ref: "v1.4.2"}).
117+
Return(newMetadataFile("resources/fixtures/.plugin.registry.yaml"), nil, nil)
118+
}),
119+
expectedError: "could not find artifact: artifact not found",
120+
},
108121
{
109122
scenario: "could not find artifact",
110123
source: "github.com/owner/my-plugin@v1.4.2",

0 commit comments

Comments
 (0)