Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Jun 8, 2023
1 parent 92aa9be commit b307864
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions internal/pkg/api/apiVersion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ func TestAPIVersion_middleware(t *testing.T) {

tests := []struct {
name string
requestApiVersionHeader string
requestAPIVersionHeader string
expectRespStatus string
expectRespApiVersionHeader string
expectRespAPIVersionHeader string
}{
{
name: "with a misformatted elastic-api-version header",
requestApiVersionHeader: "iamnotvalid",
requestAPIVersionHeader: "iamnotvalid",
expectRespStatus: "400 Bad Request",
},
{
name: "with an invalid elastic-api-version header",
requestApiVersionHeader: "1990-01-01",
requestAPIVersionHeader: "1990-01-01",
expectRespStatus: "400 Bad Request",
},
{
name: "with a valid elastic-api-version header",
requestApiVersionHeader: "2022-02-01",
expectRespApiVersionHeader: "2022-02-01",
requestAPIVersionHeader: "2022-02-01",
expectRespAPIVersionHeader: "2022-02-01",
expectRespStatus: "200 OK",
},
{
name: "without elastic-api-version header",
expectRespApiVersionHeader: "2022-03-01",
expectRespAPIVersionHeader: "2022-03-01",
expectRespStatus: "200 OK",
},
}
Expand All @@ -58,8 +58,8 @@ func TestAPIVersion_middleware(t *testing.T) {

nextHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})

if tc.requestApiVersionHeader != "" {
req.Header.Set(ElasticAPIVersionHeader, tc.requestApiVersionHeader)
if tc.requestAPIVersionHeader != "" {
req.Header.Set(ElasticAPIVersionHeader, tc.requestAPIVersionHeader)
}

apiVersion.middleware(nextHandler).ServeHTTP(resp, req)
Expand All @@ -68,8 +68,8 @@ func TestAPIVersion_middleware(t *testing.T) {
assert.Equal(t, tc.expectRespStatus, resp.Result().Status)
}

if tc.expectRespApiVersionHeader != "" {
assert.Equal(t, tc.expectRespApiVersionHeader, resp.Header().Get(ElasticAPIVersionHeader))
if tc.expectRespAPIVersionHeader != "" {
assert.Equal(t, tc.expectRespAPIVersionHeader, resp.Header().Get(ElasticAPIVersionHeader))
}
})
}
Expand Down

0 comments on commit b307864

Please sign in to comment.