Skip to content

Commit ab4d21d

Browse files
committed
Simplify dry run in client put CLI command
1 parent 9879c0d commit ab4d21d

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

tools/client-subscriptions-management/src/__tests__/entrypoint/cli/clients-put.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ describe("clients-put CLI", () => {
170170
expect(mockPutClientConfig).toHaveBeenCalledTimes(1);
171171
});
172172

173-
it("prints dry-run output without writing", async () => {
173+
it("prints dry-run output and does not log success message", async () => {
174+
mockPutClientConfig.mockResolvedValue(validConfig);
175+
174176
await cli.main([
175177
"node",
176178
"script",
@@ -184,8 +186,15 @@ describe("clients-put CLI", () => {
184186
"true",
185187
]);
186188

187-
expect(mockPutClientConfig).not.toHaveBeenCalled();
189+
expect(mockPutClientConfig).toHaveBeenCalledWith(
190+
"client-1",
191+
validConfig,
192+
true,
193+
);
188194
expect(console.log).toHaveBeenCalledWith("Dry run: config is valid");
195+
expect(console.log).toHaveBeenCalledWith(
196+
JSON.stringify(validConfig, null, 2),
197+
);
189198
});
190199

191200
it("handles errors in runCli", async () => {

tools/client-subscriptions-management/src/entrypoint/cli/clients-put.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,22 @@ export async function main(args: string[] = process.argv) {
8383
return;
8484
}
8585

86+
const repository = await createRepository(argv);
87+
88+
const result = await repository.putClientConfig(
89+
argv["client-id"],
90+
config,
91+
argv["dry-run"],
92+
);
93+
94+
console.log(`Config written for client: ${argv["client-id"]}`);
95+
8696
if (argv["dry-run"]) {
8797
console.log("Dry run: config is valid");
88-
console.log(JSON.stringify(config, null, 2));
98+
console.log(JSON.stringify(result, null, 2));
8999
return;
90100
}
91101

92-
const repository = await createRepository(argv);
93-
94-
await repository.putClientConfig(argv["client-id"], config, false);
95-
console.log(`Config written for client: ${argv["client-id"]}`);
96-
97102
if (argv["terraform-apply"]) {
98103
await runTerraformApply({
99104
environment: argv.environment,

0 commit comments

Comments
 (0)