1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
package dnsimple
import (
"context"
"io"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestVanityNameServers_vanityNameServerPath(t *testing.T) {
assert.Equal(t, "/1010/vanity/example.com", vanityNameServerPath("1010", "example.com"))
}
func TestVanityNameServersService_EnableVanityNameServers(t *testing.T) {
setupMockServer()
defer teardownMockServer()
mux.HandleFunc("/v2/1010/vanity/example.com", func(w http.ResponseWriter, r *http.Request) {
httpResponse := httpResponseFixture(t, "/api/enableVanityNameServers/success.http")
testMethod(t, r, "PUT")
testHeaders(t, r)
w.WriteHeader(httpResponse.StatusCode)
_, _ = io.Copy(w, httpResponse.Body)
})
vanityNameServerResponse, err := client.VanityNameServers.EnableVanityNameServers(context.Background(), "1010", "example.com")
assert.NoError(t, err)
delegation := vanityNameServerResponse.Data[0].Name
wantSingle := "ns1.example.com"
assert.Equal(t, wantSingle, delegation)
}
func TestVanityNameServersService_DisableVanityNameServers(t *testing.T) {
setupMockServer()
defer teardownMockServer()
mux.HandleFunc("/v2/1010/vanity/example.com", func(w http.ResponseWriter, r *http.Request) {
httpResponse := httpResponseFixture(t, "/api/disableVanityNameServers/success.http")
testMethod(t, r, "DELETE")
testHeaders(t, r)
w.WriteHeader(httpResponse.StatusCode)
_, _ = io.Copy(w, httpResponse.Body)
})
_, err := client.VanityNameServers.DisableVanityNameServers(context.Background(), "1010", "example.com")
assert.NoError(t, err)
}
|