Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BlenderistDev committed Aug 17, 2024
1 parent 3f7e6d5 commit 3fc524a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/clients/keenetic/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestList_GetDeviceList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+deviceListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
body := successRes
Expand All @@ -65,6 +66,7 @@ func TestList_GetDeviceList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+deviceListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
return nil
Expand All @@ -79,6 +81,7 @@ func TestList_GetDeviceList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+deviceListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
body := successRes
Expand All @@ -102,6 +105,7 @@ func TestList_GetDeviceList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+deviceListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
body := successRes
Expand All @@ -125,6 +129,7 @@ func TestList_GetDeviceList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+deviceListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
stringReader := strings.NewReader("")
Expand Down Expand Up @@ -162,6 +167,7 @@ func TestList_GetDeviceList(t *testing.T) {
assert.Regexp(t, tt.expectedErrStr+".*", err.Error())
} else {
assert.Equal(t, tt.expected, res)
assert.Nil(t, err)
}
})
}
Expand Down Expand Up @@ -192,10 +198,11 @@ func TestList_GetClientPolicyList(t *testing.T) {
getResponseError func() error
}{
{
name: "success get device list",
name: "success get client policy list",
validateRequest: func(req *http.Request) {
assert.Equal(t, host+clientPolicyListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
body := successRes
Expand All @@ -219,6 +226,7 @@ func TestList_GetClientPolicyList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+clientPolicyListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
return nil
Expand All @@ -233,6 +241,7 @@ func TestList_GetClientPolicyList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+clientPolicyListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
body := successRes
Expand All @@ -256,6 +265,7 @@ func TestList_GetClientPolicyList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+clientPolicyListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
body := successRes
Expand All @@ -279,6 +289,7 @@ func TestList_GetClientPolicyList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+clientPolicyListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
stringReader := strings.NewReader("")
Expand Down Expand Up @@ -316,6 +327,7 @@ func TestList_GetClientPolicyList(t *testing.T) {
assert.Regexp(t, tt.expectedErrStr+".*", err.Error())
} else {
assert.Equal(t, tt.expected, res)
assert.Nil(t, err)
}
})
}
Expand Down
6 changes: 6 additions & 0 deletions internal/clients/keenetic/policylist/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func TestPolicyList_GetPolicyList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+policyListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
body := successRes
Expand All @@ -67,6 +68,7 @@ func TestPolicyList_GetPolicyList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+policyListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
return nil
Expand All @@ -81,6 +83,7 @@ func TestPolicyList_GetPolicyList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+policyListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
body := successRes
Expand All @@ -104,6 +107,7 @@ func TestPolicyList_GetPolicyList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+policyListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
body := successRes
Expand All @@ -127,6 +131,7 @@ func TestPolicyList_GetPolicyList(t *testing.T) {
validateRequest: func(req *http.Request) {
assert.Equal(t, host+policyListUrl, req.URL.String())
assert.Equal(t, "application/json;charset=UTF-8", req.Header.Get("Content-Type"))
assert.Equal(t, http.MethodGet, req.Method)
},
getResponse: func() *http.Response {
stringReader := strings.NewReader("")
Expand Down Expand Up @@ -164,6 +169,7 @@ func TestPolicyList_GetPolicyList(t *testing.T) {
assert.Regexp(t, tt.expectedErrStr+".*", err.Error())
} else {
assert.Equal(t, tt.expected, res)
assert.Nil(t, err)
}
})
}
Expand Down

0 comments on commit 3fc524a

Please sign in to comment.