Skip to content

Commit

Permalink
fix(go-sdk): incorporate latest API changes (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh authored Dec 6, 2023
2 parents d91d019 + e8506fe commit fd1873b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 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
8 changes: 5 additions & 3 deletions config/clients/go/template/.github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.5.4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.5.4
with:
fetch-depth: 0

Expand Down Expand Up @@ -38,9 +38,11 @@ jobs:
needs: [test]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.5.4
with:
fetch-depth: 0

- uses: Roang-zero1/github-create-release-action@5cf058ddffa6fa04e5cda07c98570c757dc4a0e1
- uses: Roang-zero1/github-create-release-action@57eb9bdce7a964e48788b9e78b5ac766cb684803
with:
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+
env:
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
4 changes: 2 additions & 2 deletions config/clients/go/template/go.mod.mustache
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module {{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}

go 1.21.1
go 1.21.4

require (
github.com/jarcoal/httpmock v1.3.1
golang.org/x/sync v0.4.0
golang.org/x/sync v0.5.0
)
4 changes: 2 additions & 2 deletions config/clients/go/template/go.sum.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInw
github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg=
github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g=
github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM=
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=

0 comments on commit fd1873b

Please sign in to comment.