Skip to content

Commit

Permalink
chore: add test to cover not sending empty array when other has data
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris committed Feb 9, 2024
1 parent 3a5f658 commit c9a600c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/clients/go/template/client/client_test.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ func Test{{appShortName}}Client(t *testing.T) {
Relation: "viewer",
Object: "document:roadmap",
} },
Deletes: []ClientTupleKeyWithoutCondition{},
}
options := ClientWriteOptions{
AuthorizationModelId: {{packageName}}.PtrString("01GAHCE4YVKPQEKZQHT2R89MQV"),
Expand Down
21 changes: 21 additions & 0 deletions config/clients/js/template/tests/client.test.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,27 @@ describe("{{appTitleCaseName}} Client", () => {
writes: []
});
});

it("should properly call the {{appShortName}} Write API when providing one empty array", async () => {
const tuple = {
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "admin",
object: "workspace:1",
};
const scope = nocks.write(baseConfig.storeId!);

expect(scope.isDone()).toBe(false);
const data = await fgaClient.write({
writes: [tuple],
deletes: []
}, {
authorizationModelId: "01GXSA8YR785C4FYS3C0RTG7B1",
});

expect(scope.isDone()).toBe(true);
expect(data.writes.length).toBe(1);
expect(data.deletes.length).toBe(0);
});
});

describe("WriteTuples", () => {
Expand Down
1 change: 1 addition & 0 deletions config/clients/python/template/client/test_client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase):
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
)
],
writes=[],
)
transaction = WriteTransactionOpts(disabled=True, max_per_chunk=1, max_parallel_requests=10)
{{#asyncio}}await {{/asyncio}}api_client.write(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase):
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
)
],
writes=[],
)
transaction = WriteTransactionOpts(disabled=True, max_per_chunk=1, max_parallel_requests=10)
api_client.write(
Expand Down

0 comments on commit c9a600c

Please sign in to comment.