summaryrefslogtreecommitdiff
path: root/api/server
diff options
context:
space:
mode:
authorxin.li <xin.li@daocloud.io>2023-02-21 23:02:56 +0800
committerxin.li <xin.li@daocloud.io>2023-02-21 23:02:56 +0800
commita770153af09716f33dbe1093f8cb886570f8c378 (patch)
tree54ca3be9fa6b5e76fa84622c490d337f5bf7f053 /api/server
parent530974e7242679798c9cd256773abcc832b66ff3 (diff)
downloaddocker-a770153af09716f33dbe1093f8cb886570f8c378.tar.gz
chore: use http constants to replace numbers
Signed-off-by: xin.li <xin.li@daocloud.io>
Diffstat (limited to 'api/server')
-rw-r--r--api/server/httputils/httputils_test.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/api/server/httputils/httputils_test.go b/api/server/httputils/httputils_test.go
index 6f796feede..b2346c9224 100644
--- a/api/server/httputils/httputils_test.go
+++ b/api/server/httputils/httputils_test.go
@@ -33,7 +33,7 @@ func TestJsonContentType(t *testing.T) {
func TestReadJSON(t *testing.T) {
t.Run("nil body", func(t *testing.T) {
- req, err := http.NewRequest("POST", "https://example.com/some/path", nil)
+ req, err := http.NewRequest(http.MethodPost, "https://example.com/some/path", nil)
if err != nil {
t.Error(err)
}
@@ -45,7 +45,7 @@ func TestReadJSON(t *testing.T) {
})
t.Run("empty body", func(t *testing.T) {
- req, err := http.NewRequest("POST", "https://example.com/some/path", strings.NewReader(""))
+ req, err := http.NewRequest(http.MethodPost, "https://example.com/some/path", strings.NewReader(""))
if err != nil {
t.Error(err)
}
@@ -60,7 +60,7 @@ func TestReadJSON(t *testing.T) {
})
t.Run("with valid request", func(t *testing.T) {
- req, err := http.NewRequest("POST", "https://example.com/some/path", strings.NewReader(`{"SomeField":"some value"}`))
+ req, err := http.NewRequest(http.MethodPost, "https://example.com/some/path", strings.NewReader(`{"SomeField":"some value"}`))
if err != nil {
t.Error(err)
}
@@ -75,7 +75,7 @@ func TestReadJSON(t *testing.T) {
}
})
t.Run("with whitespace", func(t *testing.T) {
- req, err := http.NewRequest("POST", "https://example.com/some/path", strings.NewReader(`
+ req, err := http.NewRequest(http.MethodPost, "https://example.com/some/path", strings.NewReader(`
{"SomeField":"some value"}
@@ -95,7 +95,7 @@ func TestReadJSON(t *testing.T) {
})
t.Run("with extra content", func(t *testing.T) {
- req, err := http.NewRequest("POST", "https://example.com/some/path", strings.NewReader(`{"SomeField":"some value"} and more content`))
+ req, err := http.NewRequest(http.MethodPost, "https://example.com/some/path", strings.NewReader(`{"SomeField":"some value"} and more content`))
if err != nil {
t.Error(err)
}
@@ -112,7 +112,7 @@ func TestReadJSON(t *testing.T) {
})
t.Run("invalid JSON", func(t *testing.T) {
- req, err := http.NewRequest("POST", "https://example.com/some/path", strings.NewReader(`{invalid json`))
+ req, err := http.NewRequest(http.MethodPost, "https://example.com/some/path", strings.NewReader(`{invalid json`))
if err != nil {
t.Error(err)
}