Skip to content

Commit

Permalink
Fix warnings.
Browse files Browse the repository at this point in the history
Remove unused variables and resolve package variable name collisions.
  • Loading branch information
hmlanigan committed Oct 8, 2021
1 parent c3093f8 commit 92db34e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions charmhub/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (s *RefreshSuite) TestRefresh(c *gc.C) {

baseURL := MustParseURL(c, "http://api.foo.bar")

path := path.MakePath(baseURL)
baseURLPath := path.MakePath(baseURL)
id := "meshuggah"
body := transport.RefreshRequest{
Context: []transport.RefreshRequestContext{{
Expand Down Expand Up @@ -63,9 +63,9 @@ func (s *RefreshSuite) TestRefresh(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)

restClient := NewMockRESTClient(ctrl)
s.expectPost(c, restClient, path, id, body)
s.expectPost(restClient, baseURLPath, id, body)

client := NewRefreshClient(path, restClient, &FakeLogger{})
client := NewRefreshClient(baseURLPath, restClient, &FakeLogger{})
responses, err := client.Refresh(context.TODO(), config)
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(responses), gc.Equals, 1)
Expand Down Expand Up @@ -138,7 +138,7 @@ func (t *metadataTransport) Do(req *http.Request) (*http.Response, error) {

func (s *RefreshSuite) TestRefreshMetadata(c *gc.C) {
baseURL := MustParseURL(c, "http://api.foo.bar")
path := path.MakePath(baseURL)
baseURLPath := path.MakePath(baseURL)

httpTransport := &metadataTransport{
responseBody: `
Expand All @@ -160,7 +160,7 @@ func (s *RefreshSuite) TestRefreshMetadata(c *gc.C) {

headers := http.Header{"User-Agent": []string{"Test Agent 1.0"}}
restClient := NewHTTPRESTClient(httpTransport, headers)
client := NewRefreshClient(path, restClient, &FakeLogger{})
client := NewRefreshClient(baseURLPath, restClient, &FakeLogger{})

config1, err := RefreshOne("instance-key-foo", "foo", 1, "latest/stable", RefreshBase{
Name: "ubuntu",
Expand Down Expand Up @@ -201,7 +201,7 @@ func (s *RefreshSuite) TestRefreshWithMetricsOnly(c *gc.C) {

baseURL := MustParseURL(c, "http://api.foo.bar")

path := path.MakePath(baseURL)
baseURLPath := path.MakePath(baseURL)
id := ""
body := transport.RefreshRequest{
Context: []transport.RefreshRequestContext{},
Expand All @@ -213,7 +213,7 @@ func (s *RefreshSuite) TestRefreshWithMetricsOnly(c *gc.C) {
}

restClient := NewMockRESTClient(ctrl)
s.expectPost(c, restClient, path, id, body)
s.expectPost(restClient, baseURLPath, id, body)

metrics := map[charmmetrics.MetricKey]map[charmmetrics.MetricKey]string{
charmmetrics.Controller: {
Expand All @@ -227,7 +227,7 @@ func (s *RefreshSuite) TestRefreshWithMetricsOnly(c *gc.C) {
},
}

client := NewRefreshClient(path, restClient, &FakeLogger{})
client := NewRefreshClient(baseURLPath, restClient, &FakeLogger{})
err := client.RefreshWithMetricsOnly(context.TODO(), metrics)
c.Assert(err, jc.ErrorIsNil)
}
Expand All @@ -238,7 +238,7 @@ func (s *RefreshSuite) TestRefreshWithRequestMetrics(c *gc.C) {

baseURL := MustParseURL(c, "http://api.foo.bar")

p := path.MakePath(baseURL)
baseURLPath := path.MakePath(baseURL)
id := "meshuggah"
body := transport.RefreshRequest{
Context: []transport.RefreshRequestContext{{
Expand Down Expand Up @@ -294,7 +294,7 @@ func (s *RefreshSuite) TestRefreshWithRequestMetrics(c *gc.C) {
config := RefreshMany(config1, config2)

restClient := NewMockRESTClient(ctrl)
restClient.EXPECT().Post(gomock.Any(), p, gomock.Any(), body, gomock.Any()).Do(func(_ context.Context, _ path.Path, _ map[string][]string, _ transport.RefreshRequest, responses *transport.RefreshResponses) {
restClient.EXPECT().Post(gomock.Any(), baseURLPath, gomock.Any(), body, gomock.Any()).Do(func(_ context.Context, _ path.Path, _ map[string][]string, _ transport.RefreshRequest, responses *transport.RefreshResponses) {
responses.Results = []transport.RefreshResponse{{
InstanceKey: "instance-key-foo",
Name: id,
Expand All @@ -315,7 +315,7 @@ func (s *RefreshSuite) TestRefreshWithRequestMetrics(c *gc.C) {
},
}

client := NewRefreshClient(p, restClient, &FakeLogger{})
client := NewRefreshClient(baseURLPath, restClient, &FakeLogger{})
responses, err := client.RefreshWithRequestMetrics(context.TODO(), config, metrics)
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(responses), gc.Equals, 2)
Expand All @@ -328,7 +328,7 @@ func (s *RefreshSuite) TestRefreshFailure(c *gc.C) {

baseURL := MustParseURL(c, "http://api.foo.bar")

path := path.MakePath(baseURL)
baseURLPath := path.MakePath(baseURL)
name := "meshuggah"

config, err := RefreshOne("instance-key", name, 1, "latest/stable", RefreshBase{
Expand All @@ -339,14 +339,14 @@ func (s *RefreshSuite) TestRefreshFailure(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)

restClient := NewMockRESTClient(ctrl)
s.expectPostFailure(c, restClient)
s.expectPostFailure(restClient)

client := NewRefreshClient(path, restClient, &FakeLogger{})
client := NewRefreshClient(baseURLPath, restClient, &FakeLogger{})
_, err = client.Refresh(context.TODO(), config)
c.Assert(err, gc.Not(jc.ErrorIsNil))
}

func (s *RefreshSuite) expectPost(c *gc.C, client *MockRESTClient, p path.Path, name string, body interface{}) {
func (s *RefreshSuite) expectPost(client *MockRESTClient, p path.Path, name string, body interface{}) {
client.EXPECT().Post(gomock.Any(), p, gomock.Any(), body, gomock.Any()).Do(func(_ context.Context, _ path.Path, _ map[string][]string, _ transport.RefreshRequest, responses *transport.RefreshResponses) {
responses.Results = []transport.RefreshResponse{{
InstanceKey: "instance-key",
Expand All @@ -355,7 +355,7 @@ func (s *RefreshSuite) expectPost(c *gc.C, client *MockRESTClient, p path.Path,
}).Return(RESTResponse{StatusCode: http.StatusOK}, nil)
}

func (s *RefreshSuite) expectPostFailure(c *gc.C, client *MockRESTClient) {
func (s *RefreshSuite) expectPostFailure(client *MockRESTClient) {
client.EXPECT().Post(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(RESTResponse{StatusCode: http.StatusInternalServerError}, errors.Errorf("boom"))
}

Expand Down

0 comments on commit 92db34e

Please sign in to comment.