Skip to content

Commit

Permalink
server batch check - change response to have result list, not responses
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyjames committed Jan 10, 2025
1 parent d9e1770 commit 5ecf50b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions config/clients/js/template/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export type ClientBatchCheckSingleResponse = {
}

export interface ClientBatchCheckResponse {
responses: ClientBatchCheckSingleResponse[];
result: ClientBatchCheckSingleResponse[];
}

export interface ClientWriteRequestOpts {
Expand Down Expand Up @@ -750,7 +750,7 @@ export class {{appShortName}}Client extends BaseAPI {
}
}

return { responses: results };
return { result: results };
}

/**
Expand Down
16 changes: 8 additions & 8 deletions config/clients/js/template/tests/client.test.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ describe("{{appTitleCaseName}} Client", () => {
const response = await fgaClient.batchCheck({
checks: [],
});
expect(response.responses.length).toBe(0);
expect(response.result.length).toBe(0);
});
it("should handle single batch successfully", async () => {
const mockedResponse = {
Expand Down Expand Up @@ -624,9 +624,9 @@ describe("{{appTitleCaseName}} Client", () => {
});

expect(scope.isDone()).toBe(true);
expect(response.responses).toHaveLength(2);
expect(response.responses[0].allowed).toBe(true);
expect(response.responses[1].allowed).toBe(false);
expect(response.result).toHaveLength(2);
expect(response.result[0].allowed).toBe(true);
expect(response.result[1].allowed).toBe(false);
});
it("should split batches successfully", async () => {
const mockedResponse0 = {
Expand Down Expand Up @@ -698,11 +698,11 @@ describe("{{appTitleCaseName}} Client", () => {

expect(scope0.isDone()).toBe(true);
expect(scope1.isDone()).toBe(true);
expect(response.responses).toHaveLength(3);
expect(response.result).toHaveLength(3);

const resp0 = response.responses.find(r => r.correlationId === "cor-1");
const resp1 = response.responses.find(r => r.correlationId === "cor-2");
const resp2 = response.responses.find(r => r.correlationId === "cor-3");
const resp0 = response.result.find(r => r.correlationId === "cor-1");
const resp1 = response.result.find(r => r.correlationId === "cor-2");
const resp2 = response.result.find(r => r.correlationId === "cor-3");

expect(resp0?.allowed).toBe(true);
expect(resp0?.request.user).toBe("user:81684243-9356-4421-8fbf-a4f8d36aa31b");
Expand Down

0 comments on commit 5ecf50b

Please sign in to comment.