Skip to content

Commit

Permalink
Merge branch 'development' into add-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aryanmehrotra authored Dec 7, 2023
2 parents dee9c37 + c4648e5 commit 141d0d8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cmd/gofr/test/runTests.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func getIntergrationTestSchema(values *openapi3.Operation, method, endpoint stri
result.ParamsJSONString = ""
}

for k := range values.Responses {
for k := range values.Responses.Map() {
result.ExpectedResponseCode = k
// Taking only the first response as a test case
break
Expand Down
22 changes: 11 additions & 11 deletions cmd/gofr/test/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ type Swagger struct {
func (s *Swagger) convertIntoIntegrationTestSchema() IntegrationTestSchema {
resultSchema := IntegrationTestSchema{}

for k := range s.openapiSwagger.Paths {
v := s.openapiSwagger.Paths[k]
if s.openapiSwagger.Paths != nil {
for k, v := range s.openapiSwagger.Paths.Map() {
getVal := getIntergrationTestSchema(v.Get, http.MethodGet, k)
resultSchema.TestCases = populateSlice(resultSchema.TestCases, getVal)

getVal := getIntergrationTestSchema(v.Get, http.MethodGet, k)
resultSchema.TestCases = populateSlice(resultSchema.TestCases, getVal)
postVal := getIntergrationTestSchema(v.Post, http.MethodPost, k)
resultSchema.TestCases = populateSlice(resultSchema.TestCases, postVal)

postVal := getIntergrationTestSchema(v.Post, http.MethodPost, k)
resultSchema.TestCases = populateSlice(resultSchema.TestCases, postVal)
putVal := getIntergrationTestSchema(v.Put, http.MethodPut, k)
resultSchema.TestCases = populateSlice(resultSchema.TestCases, putVal)

putVal := getIntergrationTestSchema(v.Put, http.MethodPut, k)
resultSchema.TestCases = populateSlice(resultSchema.TestCases, putVal)

deleteVal := getIntergrationTestSchema(v.Delete, http.MethodDelete, k)
resultSchema.TestCases = populateSlice(resultSchema.TestCases, deleteVal)
deleteVal := getIntergrationTestSchema(v.Delete, http.MethodDelete, k)
resultSchema.TestCases = populateSlice(resultSchema.TestCases, deleteVal)
}
}

return resultSchema
Expand Down
27 changes: 9 additions & 18 deletions cmd/gofr/test/schemas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,19 @@ import (
func TestSwagger_ConvertIntoIntegrationTestSchema(t *testing.T) {
// Create a Swagger instance with test data
swagger := &Swagger{
openapiSwagger: &openapi3.T{
Paths: map[string]*openapi3.PathItem{
"/api/v1/users": {
Get: &openapi3.Operation{
OperationID: "getUser",
},
Post: &openapi3.Operation{
OperationID: "createUser",
},
},
"/api/v1/users/{id}": {
Put: &openapi3.Operation{
OperationID: "updateUser",
},
Delete: &openapi3.Operation{
OperationID: "deleteUser",
},
},
&openapi3.T{
Paths: &openapi3.Paths{
Extensions: nil,
},
},
}

swagger.openapiSwagger.Paths.Set("/api/v1/users", &openapi3.PathItem{Get: &openapi3.Operation{OperationID: "getUser"},
Post: &openapi3.Operation{OperationID: "createUser"}})

swagger.openapiSwagger.Paths.Set("/api/v1/users/{id}", &openapi3.PathItem{Put: &openapi3.Operation{OperationID: "deleteUser"},
Delete: &openapi3.Operation{OperationID: "deleteUser"}})

// Convert Swagger into IntegrationTestSchema
integrationSchema := swagger.convertIntoIntegrationTestSchema()

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.44.0
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
github.com/elastic/go-elasticsearch/v7 v7.17.10
github.com/getkin/kin-openapi v0.120.0
github.com/getkin/kin-openapi v0.122.0
github.com/go-ldap/ldap/v3 v3.4.6
github.com/go-redis/redis/extra/redisotel v0.3.0
github.com/go-redis/redis/v8 v8.11.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHqu
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/getkin/kin-openapi v0.120.0 h1:MqJcNJFrMDFNc07iwE8iFC5eT2k/NPUFDIpNeiZv8Jg=
github.com/getkin/kin-openapi v0.120.0/go.mod h1:PCWw/lfBrJY4HcdqE3jj+QFkaFK8ABoqo7PvqVhXXqw=
github.com/getkin/kin-openapi v0.122.0 h1:WB9Jbl0Hp/T79/JF9xlSW5Kl9uYdk/AWD0yAd9HOM10=
github.com/getkin/kin-openapi v0.122.0/go.mod h1:PCWw/lfBrJY4HcdqE3jj+QFkaFK8ABoqo7PvqVhXXqw=
github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD50WnA=
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
Expand Down

0 comments on commit 141d0d8

Please sign in to comment.