refactor
This commit is contained in:
parent
49563af412
commit
555c553686
18 changed files with 481 additions and 742 deletions
44
dns/service/vultr/mock_test.go
Normal file
44
dns/service/vultr/mock_test.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package vultr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/vultr/govultr/v3"
|
||||
)
|
||||
|
||||
type mock struct {
|
||||
t *testing.T
|
||||
|
||||
ListReturn map[string][]govultr.DomainRecord
|
||||
updateError error
|
||||
}
|
||||
|
||||
func (m mock) Create(ctx context.Context, domain string, domainRecordReq *govultr.DomainRecordReq) (*govultr.DomainRecord, *http.Response, error) {
|
||||
m.t.Error("Create called when it should not have been")
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (m mock) List(ctx context.Context, domain string, options *govultr.ListOptions) ([]govultr.DomainRecord, *govultr.Meta, *http.Response, error) {
|
||||
records, ok := m.ListReturn[domain]
|
||||
if !ok {
|
||||
return nil, nil, nil, errors.New("not found")
|
||||
}
|
||||
return records, nil, nil, nil
|
||||
}
|
||||
|
||||
func (m mock) Get(ctx context.Context, domain, recordID string) (*govultr.DomainRecord, *http.Response, error) {
|
||||
m.t.Error("Get called when it should not have been")
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
func (m mock) Update(ctx context.Context, domain, recordID string, domainRecordReq *govultr.DomainRecordReq) error {
|
||||
return m.updateError
|
||||
}
|
||||
|
||||
func (m mock) Delete(ctx context.Context, domain, recordID string) error {
|
||||
m.t.Error("Delete called when it should not have been")
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue