44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
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
|
|
}
|