Skip to content

Commit

Permalink
resource: move from io/ioutil to io and os packages
Browse files Browse the repository at this point in the history
Signed-off-by: Eng Zer Jun <[email protected]>
  • Loading branch information
Juneezee committed Sep 25, 2022
1 parent 5fe8e74 commit 97ff9b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions resource/charmhub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package resource_test

import (
"bytes"
"io/ioutil"
"io"

"github.com/golang/mock/gomock"
"github.com/juju/charm/v9"
Expand Down Expand Up @@ -72,7 +72,7 @@ func (s *CharmHubSuite) newCharmHubClient() *resource.CharmHubClient {
}

func (s *CharmHubSuite) expectDownloadResource() {
s.client.EXPECT().DownloadResource(gomock.Any(), gomock.Any()).Return(ioutil.NopCloser(bytes.NewBuffer([]byte{})), nil)
s.client.EXPECT().DownloadResource(gomock.Any(), gomock.Any()).Return(io.NopCloser(bytes.NewBuffer([]byte{})), nil)
}

func (s *CharmHubSuite) expectRefresh() {
Expand Down
11 changes: 5 additions & 6 deletions resource/opener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package resource_test
import (
"bytes"
"io"
"io/ioutil"
"sync"
"time"

Expand Down Expand Up @@ -184,20 +183,20 @@ func (s *OpenerSuite) expectCacheMethods(res resources.Resource, numConcurrentRe
s.resources.EXPECT().OpenResourceForUniter("postgresql/0", "wal-e").DoAndReturn(func(unitName, resName string) (resources.Resource, io.ReadCloser, error) {
s.unleash.Lock()
defer s.unleash.Unlock()
return resources.Resource{}, ioutil.NopCloser(bytes.NewBuffer([]byte{})), errors.NotFoundf("wal-e")
return resources.Resource{}, io.NopCloser(bytes.NewBuffer([]byte{})), errors.NotFoundf("wal-e")
})
} else {
s.resources.EXPECT().OpenResource("postgresql", "wal-e").Return(resources.Resource{}, ioutil.NopCloser(bytes.NewBuffer([]byte{})), errors.NotFoundf("wal-e"))
s.resources.EXPECT().OpenResource("postgresql", "wal-e").Return(resources.Resource{}, io.NopCloser(bytes.NewBuffer([]byte{})), errors.NotFoundf("wal-e"))
}
s.resources.EXPECT().GetResource("postgresql", "wal-e").Return(res, nil)
s.resources.EXPECT().SetResource("postgresql", "", res.Resource, gomock.Any(), state.DoNotIncrementCharmModifiedVersion).Return(res, nil)

other := res
other.ApplicationID = "postgreql"
if s.unitName != "" {
s.resources.EXPECT().OpenResourceForUniter("postgresql/0", "wal-e").Return(other, ioutil.NopCloser(bytes.NewBuffer([]byte{})), nil).Times(numConcurrentRequests)
s.resources.EXPECT().OpenResourceForUniter("postgresql/0", "wal-e").Return(other, io.NopCloser(bytes.NewBuffer([]byte{})), nil).Times(numConcurrentRequests)
} else {
s.resources.EXPECT().OpenResource("postgresql", "wal-e").Return(other, ioutil.NopCloser(bytes.NewBuffer([]byte{})), nil)
s.resources.EXPECT().OpenResource("postgresql", "wal-e").Return(other, io.NopCloser(bytes.NewBuffer([]byte{})), nil)
}
}

Expand All @@ -220,7 +219,7 @@ func (s *OpenerSuite) TestGetResourceErrorReleasesLock(c *gc.C) {
s.resources.EXPECT().OpenResourceForUniter("postgresql/0", "wal-e").DoAndReturn(func(unitName, resName string) (resources.Resource, io.ReadCloser, error) {
s.unleash.Lock()
defer s.unleash.Unlock()
return resources.Resource{}, ioutil.NopCloser(bytes.NewBuffer([]byte{})), errors.NotFoundf("wal-e")
return resources.Resource{}, io.NopCloser(bytes.NewBuffer([]byte{})), errors.NotFoundf("wal-e")
})
s.resources.EXPECT().GetResource("postgresql", "wal-e").Return(res, nil)
const retryCount = 3
Expand Down

0 comments on commit 97ff9b0

Please sign in to comment.