Skip to content

Commit

Permalink
fix(go): changes to required fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh committed Oct 13, 2023
1 parent ff3998b commit 1828a4f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 42 deletions.
32 changes: 16 additions & 16 deletions config/clients/go/template/api_test.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) {
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId),
func(req *http.Request) (*http.Response, error) {
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: &[]AuthorizationModel{
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{
{
Id: PtrString("01GXSA8YR785C4FYS3C0RTG7B1"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
{
Id: PtrString("01GXSBM5PVYHCJNRNKXMB4QZTW"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
}})
if err != nil {
Expand Down Expand Up @@ -238,14 +238,14 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) {
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId),
func(req *http.Request) (*http.Response, error) {
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: &[]AuthorizationModel{
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{
{
Id: PtrString("01GXSA8YR785C4FYS3C0RTG7B1"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
{
Id: PtrString("01GXSBM5PVYHCJNRNKXMB4QZTW"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
}})
if err != nil {
Expand Down Expand Up @@ -302,14 +302,14 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) {
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId),
func(req *http.Request) (*http.Response, error) {
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: &[]AuthorizationModel{
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{
{
Id: PtrString("01GXSA8YR785C4FYS3C0RTG7B1"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
{
Id: PtrString("01GXSBM5PVYHCJNRNKXMB4QZTW"),
TypeDefinitions: &[]TypeDefinition{},
TypeDefinitions: []TypeDefinition{},
},
}})
if err != nil {
Expand Down Expand Up @@ -436,12 +436,12 @@ func Test{{appShortName}}Api(t *testing.T) {
t.Fatalf("{{appShortName}}%v().Execute() = %v, want %v", test.Name, response.StatusCode, test.ResponseStatus)
}

if len(*got.AuthorizationModels) != 1 {
if len(got.AuthorizationModels) != 1 {
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 All @@ -462,7 +462,7 @@ func Test{{appShortName}}Api(t *testing.T) {
This: &map[string]interface{}{},
},
"viewer": {Union: &Usersets{
Child: &[]Userset{
Child: []Userset{
{This: &map[string]interface{}{}},
{ComputedUserset: &ObjectRelation{
Object: PtrString(""),
Expand Down Expand Up @@ -793,7 +793,7 @@ func Test{{appShortName}}Api(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Tuples) != len(*expectedResponse.Tuples) {
if len(got.Tuples) != len(expectedResponse.Tuples) {
t.Fatalf("{{appShortName}}%v().Execute() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
})
Expand Down Expand Up @@ -841,7 +841,7 @@ func Test{{appShortName}}Api(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Changes) != len(*expectedResponse.Changes) {
if len(got.Changes) != len(expectedResponse.Changes) {
t.Fatalf("{{appShortName}}%v().Execute() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
})
Expand Down Expand Up @@ -907,7 +907,7 @@ func Test{{appShortName}}Api(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Objects) != len(*expectedResponse.Objects) || (*got.Objects)[0] != (*expectedResponse.Objects)[0] {
if len(got.Objects) != len(expectedResponse.Objects) || (got.Objects)[0] != (expectedResponse.Objects)[0] {
t.Fatalf("{{appShortName}}%v().Execute() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
})
Expand Down
6 changes: 3 additions & 3 deletions config/clients/go/template/client/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ func (request *SdkClientWriteAuthorizationModelRequest) GetContext() _context.Co
func (client *{{appShortName}}Client) WriteAuthorizationModelExecute(request SdkClientWriteAuthorizationModelRequestInterface) (*ClientWriteAuthorizationModelResponse, error) {
data, _, err := client.{{appShortName}}Api.WriteAuthorizationModel(request.GetContext()).Body({{packageName}}.WriteAuthorizationModelRequest{
TypeDefinitions: request.GetBody().TypeDefinitions,
SchemaVersion: {{packageName}}.PtrString(request.GetBody().SchemaVersion),
SchemaVersion: request.GetBody().SchemaVersion,
}).Execute()
if err != nil {
return nil, err
Expand Down Expand Up @@ -946,8 +946,8 @@ func (client *{{appShortName}}Client) ReadLatestAuthorizationModelExecute(reques

var authorizationModel *{{packageName}}.AuthorizationModel

if len(*response.AuthorizationModels) > 0 {
authorizationModels := *response.AuthorizationModels
if len(response.AuthorizationModels) > 0 {
authorizationModels := response.AuthorizationModels
authorizationModel = &(authorizationModels)[0]
}

Expand Down
46 changes: 23 additions & 23 deletions config/clients/go/template/client/client_test.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ func Test{{appShortName}}Client(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Stores) != 1 {
if len(got.Stores) != 1 {
t.Fatalf("%v", err)
}

if *((*got.Stores)[0].Id) != *((*expectedResponse.Stores)[0].Id) {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, *((*got.Stores)[0].Id), *((*expectedResponse.Stores)[0].Id))
if got.Stores[0].Id != expectedResponse.Stores[0].Id {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, got.Stores[0].Id, expectedResponse.Stores[0].Id)
}
// ListStores without options should work
_, err = fgaClient.ListStores(context.Background()).Execute()
Expand Down Expand Up @@ -167,8 +167,8 @@ func Test{{appShortName}}Client(t *testing.T) {
if err != nil {
t.Fatalf("%v", err)
}
if *got.Name != *expectedResponse.Name {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, *got.Name, *expectedResponse.Name)
if got.Name != expectedResponse.Name {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, got.Name, expectedResponse.Name)
}
// CreateStore without options should work
_, err = fgaClient.CreateStore(context.Background()).Body(requestBody).Execute()
Expand Down Expand Up @@ -207,8 +207,8 @@ func Test{{appShortName}}Client(t *testing.T) {
t.Fatalf("%v", err)
}

if *got.Id != *expectedResponse.Id {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, *got.Id, *expectedResponse.Id)
if got.Id != expectedResponse.Id {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, got.Id, expectedResponse.Id)
}
// GetStore without options should work
_, err = fgaClient.GetStore(context.Background()).Execute()
Expand Down Expand Up @@ -255,11 +255,11 @@ func Test{{appShortName}}Client(t *testing.T) {
if err != nil {
t.Fatalf("%v", err)
}
if *got1.Name != *expectedResponse.Name {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, *got1.Name, *expectedResponse.Name)
if got1.Name != expectedResponse.Name {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, got1.Name, expectedResponse.Name)
}

storeId := *got1.Id
storeId := got1.Id
fgaClient.SetStoreId(storeId)

httpmock.Activate()
Expand All @@ -279,8 +279,8 @@ func Test{{appShortName}}Client(t *testing.T) {
t.Fatalf("%v", err2)
}

if *got2.Id != storeId {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, *got2.Id, storeId)
if got2.Id != storeId {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, got2.Id, storeId)
}
})

Expand Down Expand Up @@ -350,12 +350,12 @@ func Test{{appShortName}}Client(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.AuthorizationModels) != 1 {
if len(got.AuthorizationModels) != 1 {
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 @@ -383,7 +383,7 @@ func Test{{appShortName}}Client(t *testing.T) {
This: &map[string]interface{}{},
},
"viewer": {Union: &{{packageName}}.Usersets{
Child: &[]{{packageName}}.Userset{
Child: []{{packageName}}.Userset{
{This: &map[string]interface{}{}},
{ComputedUserset: &{{packageName}}.ObjectRelation{
Object: {{packageName}}.PtrString(""),
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 All @@ -542,7 +542,7 @@ func Test{{appShortName}}Client(t *testing.T) {
t.Fatalf("%v", err)
}

if (*got.AuthorizationModel).GetId() != modelId {
if got.AuthorizationModel.GetId() != modelId {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
// ReadLatestAuthorizationModel without options should work
Expand Down Expand Up @@ -592,7 +592,7 @@ func Test{{appShortName}}Client(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Changes) != len(*expectedResponse.Changes) {
if len(got.Changes) != len(expectedResponse.Changes) {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
// ReadChanges without options should work
Expand Down Expand Up @@ -648,7 +648,7 @@ func Test{{appShortName}}Client(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Tuples) != len(*expectedResponse.Tuples) {
if len(got.Tuples) != len(expectedResponse.Tuples) {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
// Read without options should work
Expand Down Expand Up @@ -1414,7 +1414,7 @@ func Test{{appShortName}}Client(t *testing.T) {
t.Fatalf("%v", err)
}

if len(*got.Objects) != len(*expectedResponse.Objects) || (*got.Objects)[0] != (*expectedResponse.Objects)[0] {
if len(got.Objects) != len(expectedResponse.Objects) || (got.Objects)[0] != (expectedResponse.Objects)[0] {
t.Fatalf("{{appShortName}}Client.%v() = %v, want %v", test.Name, string(responseJson), test.JsonResponse)
}
// ListObjects without options should work
Expand Down

0 comments on commit 1828a4f

Please sign in to comment.