Skip to content

Commit

Permalink
WD-12291 - fix: remove error notification when there are 0 models (ca…
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-cucu authored Jun 19, 2024
1 parent 0a91419 commit 62ec9c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/juju/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,26 @@ describe("Juju API", () => {
);
});

it("should fetch model statuses successfully when there are 0 models", async () => {
state.juju.models = {};
const dispatch = vi.fn();
const conn = {
facades: {
modelManager: {
modelInfo: vi.fn(),
},
},
} as unknown as Connection;
const response = fetchAllModelStatuses(
"wss://example.com/api",
[],
conn,
dispatch,
() => state,
);
await expect(response).resolves.toBeUndefined();
});

it("updates controller cloud and region", async () => {
const dispatch = vi.fn().mockReturnValue({
then: vi.fn().mockReturnValue({ catch: vi.fn() }),
Expand Down
4 changes: 2 additions & 2 deletions src/juju/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ export async function fetchAllModelStatuses(
});
return new Promise<void>((resolve, reject) => {
queue.onDone(() => {
// If errors appear in more than 10% of models, the promise should be
// If errors exist and appear in more than 10% of models, the promise is
// rejected and the error further handled in modelPollerMiddleware().
modelErrorCount >= 0.1 * modelUUIDList.length
modelErrorCount && modelErrorCount >= 0.1 * modelUUIDList.length
? reject(
new Error(
modelErrorCount === modelUUIDList.length
Expand Down

0 comments on commit 62ec9c1

Please sign in to comment.