Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yseto committed Oct 5, 2022
1 parent 0ca937d commit c8aa3a5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ func TestFindHosts(t *testing.T) {

func TestFindHostByCustomIdentifier(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.Path != "/api/v0/hosts-by-custom-identifier/mydb001" {
t.Error("request URL should be /api/v0/hosts-by-custom-identifier/mydb001 but: ", req.URL.Path)
if req.URL.RawPath != "/api/v0/hosts-by-custom-identifier/mydb001%2F001" {
t.Error("request URL.RawPath should be /api/v0/hosts-by-custom-identifier/mydb001%$2F001 but: ", req.URL.RawPath)
}

query := req.URL.Query()
Expand All @@ -172,7 +172,7 @@ func TestFindHostByCustomIdentifier(t *testing.T) {
"name": "mydb001",
"status": "working",
"memo": "hello",
"customIdentifier": "mydb001",
"customIdentifier": "mydb001/001",
},
})

Expand All @@ -182,7 +182,7 @@ func TestFindHostByCustomIdentifier(t *testing.T) {
defer ts.Close()

client, _ := NewClientWithOptions("dummy-key", ts.URL, false)
host, err := client.FindHostByCustomIdentifier("mydb001", &FindHostByCustomIdentifierParam{CaseInsensitive: true})
host, err := client.FindHostByCustomIdentifier("mydb001/001", &FindHostByCustomIdentifierParam{CaseInsensitive: true})

if err != nil {
t.Error("err should be nil but: ", err)
Expand All @@ -194,6 +194,9 @@ func TestFindHostByCustomIdentifier(t *testing.T) {
if host.ID != "9rxGOHfVF8F" {
t.Error("request sends json including ID but: ", host)
}
if host.CustomIdentifier != "mydb001/001" {
t.Error("request sends json including CustomIdentifier but: ", host)
}
}

func TestCreateHost(t *testing.T) {
Expand Down

0 comments on commit c8aa3a5

Please sign in to comment.