Skip to content

Commit

Permalink
The content type for JSON is application/json
Browse files Browse the repository at this point in the history
  • Loading branch information
sodabrew committed Aug 17, 2022
1 parent ba83c44 commit 6d33ac3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .changelog/1049.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
workers_test: Use application/json mime-type in headers
```
30 changes: 15 additions & 15 deletions workers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func TestWorkers_ListWorkerScripts(t *testing.T) {

mux.HandleFunc("/accounts/foo/workers/scripts", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, listWorkersResponseData) //nolint
})

Expand Down Expand Up @@ -903,7 +903,7 @@ func TestWorkers_CreateWorkerRoute(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/filters", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPost, r.Method, "Expected method 'POST', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, createWorkerRouteResponse) //nolint
})
route := WorkerRoute{Pattern: "app1.example.com/*", Enabled: true}
Expand All @@ -920,7 +920,7 @@ func TestWorkers_CreateWorkerRouteEnt(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/routes", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPost, r.Method, "Expected method 'POST', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, createWorkerRouteResponse) //nolint
})
route := WorkerRoute{Pattern: "app1.example.com/*", Script: "test_script"}
Expand All @@ -937,7 +937,7 @@ func TestWorkers_CreateWorkerRouteSingleScriptWithAccount(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/filters", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPost, r.Method, "Expected method 'POST', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, createWorkerRouteResponse) //nolint
})
route := WorkerRoute{Pattern: "app1.example.com/*", Enabled: true}
Expand All @@ -962,7 +962,7 @@ func TestWorkers_CreateWorkerRouteWithNoScript(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/routes", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPost, r.Method, "Expected method 'POST', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, createWorkerRouteResponse) //nolint
})

Expand All @@ -977,7 +977,7 @@ func TestWorkers_DeleteWorkerRoute(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/routes/e7a57d8746e74ae49c25994dadb421b1", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodDelete, r.Method, "Expected method 'DELETE', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, deleteWorkerRouteResponseData) //nolint
})
res, err := client.DeleteWorkerRoute(context.Background(), "foo", "e7a57d8746e74ae49c25994dadb421b1")
Expand All @@ -996,7 +996,7 @@ func TestWorkers_DeleteWorkerRouteEnt(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/routes/e7a57d8746e74ae49c25994dadb421b1", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodDelete, r.Method, "Expected method 'DELETE', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, deleteWorkerRouteResponseData) //nolint
})
res, err := client.DeleteWorkerRoute(context.Background(), "foo", "e7a57d8746e74ae49c25994dadb421b1")
Expand All @@ -1015,7 +1015,7 @@ func TestWorkers_ListWorkerRoutes(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/filters", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, listRouteResponseData) //nolint
})

Expand All @@ -1037,7 +1037,7 @@ func TestWorkers_ListWorkerRoutesEnt(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/routes", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, listRouteEntResponseData) //nolint
})

Expand All @@ -1060,7 +1060,7 @@ func TestWorkers_GetWorkerRoute(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/routes/1234", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, getRouteResponseData) //nolint
})

Expand All @@ -1082,7 +1082,7 @@ func TestWorkers_UpdateWorkerRoute(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/filters/e7a57d8746e74ae49c25994dadb421b1", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPut, r.Method, "Expected method 'PUT', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, updateWorkerRouteResponse) //nolint
})
route := WorkerRoute{Pattern: "app3.example.com/*", Enabled: true}
Expand All @@ -1104,7 +1104,7 @@ func TestWorkers_UpdateWorkerRouteEnt(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/routes/e7a57d8746e74ae49c25994dadb421b1", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPut, r.Method, "Expected method 'PUT', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, updateWorkerRouteEntResponse) //nolint
})
route := WorkerRoute{Pattern: "app3.example.com/*", Script: "test_script_1"}
Expand All @@ -1126,7 +1126,7 @@ func TestWorkers_UpdateWorkerRouteSingleScriptWithAccount(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/filters/e7a57d8746e74ae49c25994dadb421b1", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPut, r.Method, "Expected method 'PUT', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, updateWorkerRouteEntResponse) //nolint
})
route := WorkerRoute{Pattern: "app3.example.com/*", Enabled: true}
Expand All @@ -1148,7 +1148,7 @@ func TestWorkers_ListWorkerBindingsMultiScript(t *testing.T) {

mux.HandleFunc("/accounts/foo/workers/scripts/my-script/bindings", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, listBindingsResponseData) //nolint
})

Expand Down Expand Up @@ -1235,7 +1235,7 @@ func TestWorkers_UpdateWorkerRouteWithNoScript(t *testing.T) {

mux.HandleFunc("/zones/foo/workers/routes/e7a57d8746e74ae49c25994dadb421b1", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPut, r.Method, "Expected method 'PUT', got %s", r.Method)
w.Header().Set("content-type", "application-json")
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, updateWorkerRouteEntResponse) //nolint
})

Expand Down

0 comments on commit 6d33ac3

Please sign in to comment.