Skip to content

Commit

Permalink
Revert "Lint: apply common initialisms"
Browse files Browse the repository at this point in the history
This reverts commit 3cdeb31.
  • Loading branch information
Jamie Tanna committed Nov 12, 2022
1 parent 677718e commit f36b5a7
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 50 deletions.
10 changes: 5 additions & 5 deletions examples/authenticated-api/echo/server/server_test.go
Expand Up @@ -40,23 +40,23 @@ func TestAPI(t *testing.T) {
// Using the writer JWT should allow us to insert a thing.
response = testutil.NewRequest().Post("/things").
WithJWSAuth(string(writerJWT)).
WithAcceptJSON().
WithJSONBody(api.Thing{Name: "Thing 1"}).Go(t, e)
WithAcceptJson().
WithJsonBody(api.Thing{Name: "Thing 1"}).Go(t, e)
require.Equal(t, http.StatusCreated, response.Code())

// Using the reader JWT should forbid inserting a thing.
response = testutil.NewRequest().Post("/things").
WithJWSAuth(string(readerJWT)).
WithAcceptJSON().
WithJSONBody(api.Thing{Name: "Thing 2"}).Go(t, e)
WithAcceptJson().
WithJsonBody(api.Thing{Name: "Thing 2"}).Go(t, e)
require.Equal(t, http.StatusForbidden, response.Code())

// Both JWT's should allow reading the list of things.
jwts := []string{string(readerJWT), string(writerJWT)}
for _, jwt := range jwts {
response := testutil.NewRequest().Get("/things").
WithJWSAuth(jwt).
WithAcceptJSON().Go(t, e)
WithAcceptJson().Go(t, e)
assert.Equal(t, http.StatusOK, response.Code())
}
}
4 changes: 2 additions & 2 deletions examples/petstore-expanded/chi/petstore_test.go
Expand Up @@ -16,7 +16,7 @@ import (
)

func doGet(t *testing.T, mux *chi.Mux, url string) *httptest.ResponseRecorder {
response := testutil.NewRequest().Get(url).WithAcceptJSON().GoWithHTTPHandler(t, mux)
response := testutil.NewRequest().Get(url).WithAcceptJson().GoWithHTTPHandler(t, mux)
return response.Recorder
}

Expand Down Expand Up @@ -48,7 +48,7 @@ func TestPetStore(t *testing.T) {
Tag: &tag,
}

rr := testutil.NewRequest().Post("/pets").WithJSONBody(newPet).GoWithHTTPHandler(t, r).Recorder
rr := testutil.NewRequest().Post("/pets").WithJsonBody(newPet).GoWithHTTPHandler(t, r).Recorder
assert.Equal(t, http.StatusCreated, rr.Code)

var resultPet api.Pet
Expand Down
16 changes: 8 additions & 8 deletions examples/petstore-expanded/echo/petstore_test.go
Expand Up @@ -64,7 +64,7 @@ func TestPetStore(t *testing.T) {
Name: "Spot",
Tag: &tag,
}
result := testutil.NewRequest().Post("/pets").WithJSONBody(newPet).Go(t, e)
result := testutil.NewRequest().Post("/pets").WithJsonBody(newPet).Go(t, e)
// We expect 201 code on successful pet insertion
assert.Equal(t, http.StatusCreated, result.Code())

Expand All @@ -80,14 +80,14 @@ func TestPetStore(t *testing.T) {
petId := resultPet.Id

// Test the getter function.
result = testutil.NewRequest().Get(fmt.Sprintf("/pets/%d", petId)).WithAcceptJSON().Go(t, e)
result = testutil.NewRequest().Get(fmt.Sprintf("/pets/%d", petId)).WithAcceptJson().Go(t, e)
var resultPet2 models.Pet
err = result.UnmarshalBodyToObject(&resultPet2)
assert.NoError(t, err, "error getting pet")
assert.Equal(t, resultPet, resultPet2)

// We should get a 404 on invalid ID
result = testutil.NewRequest().Get("/pets/27179095781").WithAcceptJSON().Go(t, e)
result = testutil.NewRequest().Get("/pets/27179095781").WithAcceptJson().Go(t, e)
assert.Equal(t, http.StatusNotFound, result.Code())
var petError models.Error
err = result.UnmarshalBodyToObject(&petError)
Expand All @@ -100,7 +100,7 @@ func TestPetStore(t *testing.T) {
Name: "Fido",
Tag: &tag,
}
result = testutil.NewRequest().Post("/pets").WithJSONBody(newPet).Go(t, e)
result = testutil.NewRequest().Post("/pets").WithJsonBody(newPet).Go(t, e)
// We expect 201 code on successful pet insertion
assert.Equal(t, http.StatusCreated, result.Code())
// We should have gotten a response from the server with the new pet. Make
Expand All @@ -110,7 +110,7 @@ func TestPetStore(t *testing.T) {
petId2 := resultPet.Id

// Now, list all pets, we should have two
result = testutil.NewRequest().Get("/pets").WithAcceptJSON().Go(t, e)
result = testutil.NewRequest().Get("/pets").WithAcceptJson().Go(t, e)
assert.Equal(t, http.StatusOK, result.Code())
var petList []models.Pet
err = result.UnmarshalBodyToObject(&petList)
Expand All @@ -119,15 +119,15 @@ func TestPetStore(t *testing.T) {

// Filter pets by tag, we should have 1
petList = nil
result = testutil.NewRequest().Get("/pets?tags=TagOfFido").WithAcceptJSON().Go(t, e)
result = testutil.NewRequest().Get("/pets?tags=TagOfFido").WithAcceptJson().Go(t, e)
assert.Equal(t, http.StatusOK, result.Code())
err = result.UnmarshalBodyToObject(&petList)
assert.NoError(t, err, "error getting response", err)
assert.Equal(t, 1, len(petList))

// Filter pets by non existent tag, we should have 0
petList = nil
result = testutil.NewRequest().Get("/pets?tags=NotExists").WithAcceptJSON().Go(t, e)
result = testutil.NewRequest().Get("/pets?tags=NotExists").WithAcceptJson().Go(t, e)
assert.Equal(t, http.StatusOK, result.Code())
err = result.UnmarshalBodyToObject(&petList)
assert.NoError(t, err, "error getting response", err)
Expand All @@ -148,7 +148,7 @@ func TestPetStore(t *testing.T) {

// Should have no pets left.
petList = nil
result = testutil.NewRequest().Get("/pets").WithAcceptJSON().Go(t, e)
result = testutil.NewRequest().Get("/pets").WithAcceptJson().Go(t, e)
assert.Equal(t, http.StatusOK, result.Code())
err = result.UnmarshalBodyToObject(&petList)
assert.NoError(t, err, "error getting response", err)
Expand Down
4 changes: 2 additions & 2 deletions examples/petstore-expanded/gin/petstore_test.go
Expand Up @@ -13,7 +13,7 @@ import (
)

func doGet(t *testing.T, handler http.Handler, url string) *httptest.ResponseRecorder {
response := testutil.NewRequest().Get(url).WithAcceptJSON().GoWithHTTPHandler(t, handler)
response := testutil.NewRequest().Get(url).WithAcceptJson().GoWithHTTPHandler(t, handler)
return response.Recorder
}

Expand All @@ -30,7 +30,7 @@ func TestPetStore(t *testing.T) {
Tag: &tag,
}

rr := testutil.NewRequest().Post("/pets").WithJSONBody(newPet).GoWithHTTPHandler(t, r).Recorder
rr := testutil.NewRequest().Post("/pets").WithJsonBody(newPet).GoWithHTTPHandler(t, r).Recorder
assert.Equal(t, http.StatusCreated, rr.Code)

var resultPet api.Pet
Expand Down
4 changes: 2 additions & 2 deletions examples/petstore-expanded/gorilla/petstore_test.go
Expand Up @@ -16,7 +16,7 @@ import (
)

func doGet(t *testing.T, mux *mux.Router, url string) *httptest.ResponseRecorder {
response := testutil.NewRequest().Get(url).WithAcceptJSON().GoWithHTTPHandler(t, mux)
response := testutil.NewRequest().Get(url).WithAcceptJson().GoWithHTTPHandler(t, mux)
return response.Recorder
}

Expand Down Expand Up @@ -48,7 +48,7 @@ func TestPetStore(t *testing.T) {
Tag: &tag,
}

rr := testutil.NewRequest().Post("/pets").WithJSONBody(newPet).GoWithHTTPHandler(t, r).Recorder
rr := testutil.NewRequest().Post("/pets").WithJsonBody(newPet).GoWithHTTPHandler(t, r).Recorder
assert.Equal(t, http.StatusCreated, rr.Code)

var resultPet api.Pet
Expand Down
4 changes: 2 additions & 2 deletions examples/petstore-expanded/strict/petstore_test.go
Expand Up @@ -16,7 +16,7 @@ import (
)

func doGet(t *testing.T, mux *chi.Mux, url string) *httptest.ResponseRecorder {
response := testutil.NewRequest().Get(url).WithAcceptJSON().GoWithHTTPHandler(t, mux)
response := testutil.NewRequest().Get(url).WithAcceptJson().GoWithHTTPHandler(t, mux)
return response.Recorder
}

Expand Down Expand Up @@ -48,7 +48,7 @@ func TestPetStore(t *testing.T) {
Tag: &tag,
}

rr := testutil.NewRequest().Post("/pets").WithJSONBody(newPet).GoWithHTTPHandler(t, r).Recorder
rr := testutil.NewRequest().Post("/pets").WithJsonBody(newPet).GoWithHTTPHandler(t, r).Recorder
assert.Equal(t, http.StatusOK, rr.Code)

var resultPet api.Pet
Expand Down
18 changes: 9 additions & 9 deletions internal/test/components/components_test.go
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
)

func assertJSONEqual(t *testing.T, j1 []byte, j2 []byte) {
func assertJsonEqual(t *testing.T, j1 []byte, j2 []byte) {
var v1, v2 interface{}

err := json.Unmarshal(j1, &v1)
Expand All @@ -29,7 +29,7 @@ func TestRawJSON(t *testing.T) {
buf2, err := json.Marshal(dst)
assert.NoError(t, err)

assertJSONEqual(t, []byte(buf), buf2)
assertJsonEqual(t, []byte(buf), buf2)

}

Expand Down Expand Up @@ -99,19 +99,19 @@ func TestOneOf(t *testing.T) {
assert.NoError(t, err)
marshaled, err := json.Marshal(dst)
assert.NoError(t, err)
assertJSONEqual(t, []byte(variant1), marshaled)
assertJsonEqual(t, []byte(variant1), marshaled)

err = dst.FromOneOfVariant2([]int{1, 2, 3})
assert.NoError(t, err)
marshaled, err = json.Marshal(dst)
assert.NoError(t, err)
assertJSONEqual(t, []byte(variant2), marshaled)
assertJsonEqual(t, []byte(variant2), marshaled)

err = dst.FromOneOfVariant3(true)
assert.NoError(t, err)
marshaled, err = json.Marshal(dst)
assert.NoError(t, err)
assertJSONEqual(t, []byte(variant3), marshaled)
assertJsonEqual(t, []byte(variant3), marshaled)
}

func TestOneOfWithDiscriminator(t *testing.T) {
Expand Down Expand Up @@ -142,13 +142,13 @@ func TestOneOfWithDiscriminator(t *testing.T) {
assert.NoError(t, err)
marshaled, err := json.Marshal(dst)
assert.NoError(t, err)
assertJSONEqual(t, []byte(variant4), marshaled)
assertJsonEqual(t, []byte(variant4), marshaled)

err = dst.FromOneOfVariant5(OneOfVariant5{Id: 123})
assert.NoError(t, err)
marshaled, err = json.Marshal(dst)
assert.NoError(t, err)
assertJSONEqual(t, []byte(variant5), marshaled)
assertJsonEqual(t, []byte(variant5), marshaled)
}

func TestOneOfWithFixedProperties(t *testing.T) {
Expand Down Expand Up @@ -178,13 +178,13 @@ func TestOneOfWithFixedProperties(t *testing.T) {
assert.NoError(t, err)
marshaled, err := json.Marshal(dst)
assert.NoError(t, err)
assertJSONEqual(t, []byte(variant1), marshaled)
assertJsonEqual(t, []byte(variant1), marshaled)

err = dst.FromOneOfVariant6(OneOfVariant6{[]int{1, 2, 3}})
assert.NoError(t, err)
marshaled, err = json.Marshal(dst)
assert.NoError(t, err)
assertJSONEqual(t, []byte(variant6), marshaled)
assertJsonEqual(t, []byte(variant6), marshaled)
}

func TestAnyOf(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/test/issues/issue-312/issue_test.go
Expand Up @@ -112,9 +112,9 @@ type MockClient struct {
validatePets func(ctx echo.Context) error
}

func (m *MockClient) GetPet(ctx echo.Context, petID string) error {
func (m *MockClient) GetPet(ctx echo.Context, petId string) error {
if m.getPet != nil {
return m.getPet(ctx, petID)
return m.getPet(ctx, petId)
}
return ctx.NoContent(http.StatusNotImplemented)
}
Expand Down
10 changes: 5 additions & 5 deletions internal/test/strict-server/strict_test.go
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"testing"

api "github.com/deepmap/oapi-codegen/internal/test/strict-server/chi"
"github.com/deepmap/oapi-codegen/internal/test/strict-server/chi"
api3 "github.com/deepmap/oapi-codegen/internal/test/strict-server/client"
api4 "github.com/deepmap/oapi-codegen/internal/test/strict-server/echo"
api2 "github.com/deepmap/oapi-codegen/internal/test/strict-server/gin"
Expand Down Expand Up @@ -52,7 +52,7 @@ func testImpl(t *testing.T, handler http.Handler) {
t.Run("JSONExample", func(t *testing.T) {
value := "123"
requestBody := api3.Example{Value: &value}
rr := testutil.NewRequest().Post("/json").WithJSONBody(requestBody).GoWithHTTPHandler(t, handler).Recorder
rr := testutil.NewRequest().Post("/json").WithJsonBody(requestBody).GoWithHTTPHandler(t, handler).Recorder
assert.Equal(t, http.StatusOK, rr.Code)
assert.True(t, strings.HasPrefix(rr.Header().Get("Content-Type"), "application/json"))
var responseBody api3.Example
Expand Down Expand Up @@ -116,7 +116,7 @@ func testImpl(t *testing.T, handler http.Handler) {
t.Run("MultipleRequestAndResponseTypesJSON", func(t *testing.T) {
value := "123"
requestBody := api3.Example{Value: &value}
rr := testutil.NewRequest().Post("/multiple").WithJSONBody(requestBody).GoWithHTTPHandler(t, handler).Recorder
rr := testutil.NewRequest().Post("/multiple").WithJsonBody(requestBody).GoWithHTTPHandler(t, handler).Recorder
assert.Equal(t, http.StatusOK, rr.Code)
assert.True(t, strings.HasPrefix(rr.Header().Get("Content-Type"), "application/json"))
var responseBody api3.Example
Expand Down Expand Up @@ -182,7 +182,7 @@ func testImpl(t *testing.T, handler http.Handler) {
header2 := "890"
value := "asdf"
requestBody := api3.Example{Value: &value}
rr := testutil.NewRequest().Post("/with-headers").WithHeader("header1", header1).WithHeader("header2", header2).WithJSONBody(requestBody).GoWithHTTPHandler(t, handler).Recorder
rr := testutil.NewRequest().Post("/with-headers").WithHeader("header1", header1).WithHeader("header2", header2).WithJsonBody(requestBody).GoWithHTTPHandler(t, handler).Recorder
assert.Equal(t, http.StatusOK, rr.Code)
assert.True(t, strings.HasPrefix(rr.Header().Get("Content-Type"), "application/json"))
var responseBody api3.Example
Expand All @@ -203,7 +203,7 @@ func testImpl(t *testing.T, handler http.Handler) {
t.Run("ReusableResponses", func(t *testing.T) {
value := "jkl;"
requestBody := api3.Example{Value: &value}
rr := testutil.NewRequest().Post("/reusable-responses").WithJSONBody(requestBody).GoWithHTTPHandler(t, handler).Recorder
rr := testutil.NewRequest().Post("/reusable-responses").WithJsonBody(requestBody).GoWithHTTPHandler(t, handler).Recorder
assert.Equal(t, http.StatusOK, rr.Code)
assert.True(t, strings.HasPrefix(rr.Header().Get("Content-Type"), "application/json"))
var responseBody api3.Example
Expand Down
4 changes: 2 additions & 2 deletions pkg/chi-middleware/oapi_validate_test.go
Expand Up @@ -27,7 +27,7 @@ func doGet(t *testing.T, mux *chi.Mux, rawURL string) *httptest.ResponseRecorder
t.Fatalf("Invalid url: %s", rawURL)
}

response := testutil.NewRequest().Get(u.RequestURI()).WithHost(u.Host).WithAcceptJSON().GoWithHTTPHandler(t, mux)
response := testutil.NewRequest().Get(u.RequestURI()).WithHost(u.Host).WithAcceptJson().GoWithHTTPHandler(t, mux)
return response.Recorder
}

Expand All @@ -37,7 +37,7 @@ func doPost(t *testing.T, mux *chi.Mux, rawURL string, jsonBody interface{}) *ht
t.Fatalf("Invalid url: %s", rawURL)
}

response := testutil.NewRequest().Post(u.RequestURI()).WithHost(u.Host).WithJSONBody(jsonBody).GoWithHTTPHandler(t, mux)
response := testutil.NewRequest().Post(u.RequestURI()).WithHost(u.Host).WithJsonBody(jsonBody).GoWithHTTPHandler(t, mux)
return response.Recorder
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/gin-middleware/oapi_validate_test.go
Expand Up @@ -42,7 +42,7 @@ func doGet(t *testing.T, handler http.Handler, rawURL string) *httptest.Response
t.Fatalf("Invalid url: %s", rawURL)
}

response := testutil.NewRequest().Get(u.RequestURI()).WithHost(u.Host).WithAcceptJSON().GoWithHTTPHandler(t, handler)
response := testutil.NewRequest().Get(u.RequestURI()).WithHost(u.Host).WithAcceptJson().GoWithHTTPHandler(t, handler)
return response.Recorder
}

Expand All @@ -52,7 +52,7 @@ func doPost(t *testing.T, handler http.Handler, rawURL string, jsonBody interfac
t.Fatalf("Invalid url: %s", rawURL)
}

response := testutil.NewRequest().Post(u.RequestURI()).WithHost(u.Host).WithJSONBody(jsonBody).GoWithHTTPHandler(t, handler)
response := testutil.NewRequest().Post(u.RequestURI()).WithHost(u.Host).WithJsonBody(jsonBody).GoWithHTTPHandler(t, handler)
return response.Recorder
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/middleware/oapi_validate_test.go
Expand Up @@ -42,7 +42,7 @@ func doGet(t *testing.T, e *echo.Echo, rawURL string) *httptest.ResponseRecorder
t.Fatalf("Invalid url: %s", rawURL)
}

response := testutil.NewRequest().Get(u.RequestURI()).WithHost(u.Host).WithAcceptJSON().GoWithHTTPHandler(t, e)
response := testutil.NewRequest().Get(u.RequestURI()).WithHost(u.Host).WithAcceptJson().GoWithHTTPHandler(t, e)
return response.Recorder
}

Expand All @@ -52,7 +52,7 @@ func doPost(t *testing.T, e *echo.Echo, rawURL string, jsonBody interface{}) *ht
t.Fatalf("Invalid url: %s", rawURL)
}

response := testutil.NewRequest().Post(u.RequestURI()).WithHost(u.Host).WithJSONBody(jsonBody).GoWithHTTPHandler(t, e)
response := testutil.NewRequest().Post(u.RequestURI()).WithHost(u.Host).WithJsonBody(jsonBody).GoWithHTTPHandler(t, e)
return response.Recorder
}

Expand Down

0 comments on commit f36b5a7

Please sign in to comment.