chore(all): return concrete types, accept interfaces

- Remove exported interfaces unused locally
- Define interfaces to accept arguments
- Return concrete types, not interfaces
This commit is contained in:
Quentin McGaw
2022-06-11 01:34:30 +00:00
parent 0378fe4a7b
commit 578ef768ab
132 changed files with 594 additions and 935 deletions

View File

@@ -12,7 +12,7 @@ var (
ErrHTTPStatusCodeNotOK = errors.New("HTTP status code not OK")
)
func (u *unzipper) FetchAndExtract(ctx context.Context, url string) (
func (u *Unzipper) FetchAndExtract(ctx context.Context, url string) (
contents map[string][]byte, err error) {
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {

View File

@@ -1,50 +0,0 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/qdm12/gluetun/internal/updater/unzip (interfaces: Unzipper)
// Package mock_unzip is a generated GoMock package.
package mock_unzip
import (
context "context"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
)
// MockUnzipper is a mock of Unzipper interface.
type MockUnzipper struct {
ctrl *gomock.Controller
recorder *MockUnzipperMockRecorder
}
// MockUnzipperMockRecorder is the mock recorder for MockUnzipper.
type MockUnzipperMockRecorder struct {
mock *MockUnzipper
}
// NewMockUnzipper creates a new mock instance.
func NewMockUnzipper(ctrl *gomock.Controller) *MockUnzipper {
mock := &MockUnzipper{ctrl: ctrl}
mock.recorder = &MockUnzipperMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockUnzipper) EXPECT() *MockUnzipperMockRecorder {
return m.recorder
}
// FetchAndExtract mocks base method.
func (m *MockUnzipper) FetchAndExtract(arg0 context.Context, arg1 string) (map[string][]byte, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "FetchAndExtract", arg0, arg1)
ret0, _ := ret[0].(map[string][]byte)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// FetchAndExtract indicates an expected call of FetchAndExtract.
func (mr *MockUnzipperMockRecorder) FetchAndExtract(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchAndExtract", reflect.TypeOf((*MockUnzipper)(nil).FetchAndExtract), arg0, arg1)
}

View File

@@ -3,22 +3,15 @@
package unzip
import (
"context"
"net/http"
)
//go:generate mockgen -destination=mock_$GOPACKAGE/$GOFILE . Unzipper
type Unzipper interface {
FetchAndExtract(ctx context.Context, url string) (contents map[string][]byte, err error)
}
type unzipper struct {
type Unzipper struct {
client *http.Client
}
func New(client *http.Client) Unzipper {
return &unzipper{
func New(client *http.Client) *Unzipper {
return &Unzipper{
client: client,
}
}