Skip to content

Commit

Permalink
fix(go-sdk): incorporate latest API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh committed Dec 6, 2023
1 parent 7df3af2 commit e8506fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Main config
OPENFGA_DOCKER_TAG = latest
OPEN_API_URL = https://raw.githubusercontent.com/openfga/api/feat/abac/docs/openapiv2/apidocs.swagger.json
OPEN_API_URL = https://raw.githubusercontent.com/openfga/api/main/docs/openapiv2/apidocs.swagger.json
OPENAPI_GENERATOR_CLI_DOCKER_TAG = v6.4.0
NODE_DOCKER_TAG = 18-alpine
GO_DOCKER_TAG = 1
Expand Down
20 changes: 10 additions & 10 deletions config/clients/go/template/api_test.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) {
func(req *http.Request) (*http.Response, error) {
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{
{
Id: PtrString("01GXSA8YR785C4FYS3C0RTG7B1"),
Id: "01GXSA8YR785C4FYS3C0RTG7B1",
TypeDefinitions: []TypeDefinition{},
},
{
Id: PtrString("01GXSBM5PVYHCJNRNKXMB4QZTW"),
Id: "01GXSBM5PVYHCJNRNKXMB4QZTW",
TypeDefinitions: []TypeDefinition{},
},
}})
Expand Down Expand Up @@ -240,11 +240,11 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) {
func(req *http.Request) (*http.Response, error) {
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{
{
Id: PtrString("01GXSA8YR785C4FYS3C0RTG7B1"),
Id: "01GXSA8YR785C4FYS3C0RTG7B1",
TypeDefinitions: []TypeDefinition{},
},
{
Id: PtrString("01GXSBM5PVYHCJNRNKXMB4QZTW"),
Id: "01GXSBM5PVYHCJNRNKXMB4QZTW",
TypeDefinitions: []TypeDefinition{},
},
}})
Expand Down Expand Up @@ -304,11 +304,11 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) {
func(req *http.Request) (*http.Response, error) {
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{
{
Id: PtrString("01GXSA8YR785C4FYS3C0RTG7B1"),
Id: "01GXSA8YR785C4FYS3C0RTG7B1",
TypeDefinitions: []TypeDefinition{},
},
{
Id: PtrString("01GXSBM5PVYHCJNRNKXMB4QZTW"),
Id: "01GXSBM5PVYHCJNRNKXMB4QZTW",
TypeDefinitions: []TypeDefinition{},
},
}})
Expand Down Expand Up @@ -440,8 +440,8 @@ func Test{{appShortName}}Api(t *testing.T) {
t.Fatalf("%v", err)
}

if *(got.AuthorizationModels[0].Id) != *(expectedResponse.AuthorizationModels[0].Id) {
t.Fatalf("{{appShortName}}%v().Execute() = %v, want %v", test.Name, *(got.AuthorizationModels[0].Id), *(expectedResponse.AuthorizationModels[0].Id))
if got.AuthorizationModels[0].Id != expectedResponse.AuthorizationModels[0].Id {
t.Fatalf("{{appShortName}}%v().Execute() = %v, want %v", test.Name, got.AuthorizationModels[0].Id, expectedResponse.AuthorizationModels[0].Id)
}
})

Expand Down Expand Up @@ -519,7 +519,7 @@ func Test{{appShortName}}Api(t *testing.T) {
if err := json.Unmarshal([]byte(test.JsonResponse), &expectedResponse); err != nil {
t.Fatalf("%v", err)
}
modelId := *(*expectedResponse.AuthorizationModel).Id
modelId := expectedResponse.AuthorizationModel.Id

httpmock.Activate()
defer httpmock.DeactivateAndReset()
Expand All @@ -546,7 +546,7 @@ func Test{{appShortName}}Api(t *testing.T) {
t.Fatalf("%v", err)
}

if *(*got.AuthorizationModel).Id != modelId {
if got.AuthorizationModel.Id != modelId {
t.Fatalf("{{appShortName}}%v().Execute() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
})
Expand Down
10 changes: 5 additions & 5 deletions config/clients/go/template/client/client_test.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ func Test{{appShortName}}Client(t *testing.T) {
t.Fatalf("%v", err)
}

if *(got.AuthorizationModels[0].Id) != *(expectedResponse.AuthorizationModels[0].Id) {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, *(got.AuthorizationModels[0].Id), *(expectedResponse.AuthorizationModels[0].Id))
if got.AuthorizationModels[0].Id != expectedResponse.AuthorizationModels[0].Id {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, got.AuthorizationModels[0].Id, expectedResponse.AuthorizationModels[0].Id)
}
// ReadAuthorizationModels without options should work
_, err = fgaClient.ReadAuthorizationModels(context.Background()).Execute()
Expand Down Expand Up @@ -460,7 +460,7 @@ func Test{{appShortName}}Client(t *testing.T) {
if err := json.Unmarshal([]byte(test.JsonResponse), &expectedResponse); err != nil {
t.Fatalf("%v", err)
}
modelId := *(expectedResponse.AuthorizationModel).Id
modelId := expectedResponse.AuthorizationModel.Id

httpmock.Activate()
defer httpmock.DeactivateAndReset()
Expand All @@ -486,7 +486,7 @@ func Test{{appShortName}}Client(t *testing.T) {
t.Fatalf("%v", err)
}

if *(got.AuthorizationModel).Id != modelId {
if got.AuthorizationModel.Id != modelId {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
// ReadAuthorizationModel without options should not work
Expand Down Expand Up @@ -518,7 +518,7 @@ func Test{{appShortName}}Client(t *testing.T) {
if err := json.Unmarshal([]byte(test.JsonResponse), &expectedResponse); err != nil {
t.Fatalf("%v", err)
}
modelId := *(expectedResponse.AuthorizationModels[0].Id)
modelId := expectedResponse.AuthorizationModels[0].Id

httpmock.Activate()
defer httpmock.DeactivateAndReset()
Expand Down

0 comments on commit e8506fe

Please sign in to comment.