Skip to content

Commit 6680610

Browse files
committed
Better error message for partial create success
1 parent 750c3a5 commit 6680610

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/commands/appdistribution-testcases-import.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { AppDistributionClient } from "../appdistribution/client";
66
import { getAppName, ensureFileExists } from "../appdistribution/options-parser-util";
77
import { TestCase } from "../appdistribution/types";
88
import * as utils from "../utils";
9+
import { FirebaseError } from "../error";
910

1011
export const command = new Command("appdistribution:testcases:import <test-cases-yaml-file>")
1112
.description("import test cases from YAML file")
@@ -19,9 +20,19 @@ export const command = new Command("appdistribution:testcases:import <test-cases
1920
const testCasesWithoutName = testCases.filter((tc) => !tc.name);
2021
// nothing can depend on these test cases yet, since they don't have
2122
// resource names
22-
await Promise.all(
23+
const creationResults = await Promise.allSettled(
2324
testCasesWithoutName.map((tc) => appDistroClient.createTestCase(appName, tc)),
2425
);
26+
const failed = creationResults.filter((r) => r.status === "rejected");
27+
if (failed.length > 0) {
28+
for (const f of failed) {
29+
utils.logWarning((f as any).reason);
30+
}
31+
const succeeded = creationResults.length - failed.length;
32+
throw new FirebaseError(
33+
`Created ${succeeded} test case(s), but failed to create ${failed.length}.`,
34+
);
35+
}
2536
// any test case with a resource name can be referenced by any other new or
2637
// existing test case, so we need to batch the upsert.
2738
const testCasesWithName = testCases.filter((tc) => !!tc.name);

0 commit comments

Comments
 (0)