Skip to content

Commit

Permalink
test: add ut to raise code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
HuihuiWu-Microsoft committed Jan 8, 2025
1 parent 1c6baeb commit ec8c9bc
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions packages/fx-core/tests/component/coordinator/coordinator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,62 @@ describe("component coordinator test", () => {
assert.isTrue(res.isOk());
});

it("preCheckYmlAndEnvForVS - happy pass with empty provision actions", async () => {
const mockProjectModel: ProjectModel = {
version: "1.0.0",
};
sandbox.stub(metadataUtil, "parse").resolves(ok(mockProjectModel));
sandbox.stub(envUtil, "readEnv").resolves(ok({}));
sandbox.stub(envUtil, "writeEnv").resolves(ok(undefined));
sandbox.stub(pathUtils, "getEnvFilePath").resolves(ok("."));
sandbox.stub(fs, "pathExistsSync").returns(true);
const inputs: Inputs = {
platform: Platform.VSCode,
projectPath: ".",
env: "local",
ignoreLockByUT: true,
};
const fxCore = new FxCore(tools);
const res = await fxCore.preCheckYmlAndEnvForVS(inputs);
assert.isTrue(res.isOk());
});

it("preCheckYmlAndEnvForVS - happy pass without teamsApp/create action", async () => {
const mockProjectModel: ProjectModel = {
version: "1.0.0",
provision: {
name: "configureApp",
driverDefs: [
{
uses: "botFramework/create",
with: undefined,
},
],
resolvePlaceholders: () => {
return [];
},
execute: async (ctx: DriverContext): Promise<ExecutionResult> => {
return { result: ok(new Map()), summaries: [] };
},
resolveDriverInstances: mockedResolveDriverInstances,
},
};
sandbox.stub(metadataUtil, "parse").resolves(ok(mockProjectModel));
sandbox.stub(envUtil, "readEnv").resolves(ok({}));
sandbox.stub(envUtil, "writeEnv").resolves(ok(undefined));
sandbox.stub(pathUtils, "getEnvFilePath").resolves(ok("."));
sandbox.stub(fs, "pathExistsSync").returns(true);
const inputs: Inputs = {
platform: Platform.VSCode,
projectPath: ".",
env: "local",
ignoreLockByUT: true,
};
const fxCore = new FxCore(tools);
const res = await fxCore.preCheckYmlAndEnvForVS(inputs);
assert.isTrue(res.isOk());
});

it("fail to get project model in preCheckYmlAndEnvForVS", async () => {
sandbox.stub(metadataUtil, "parse").resolves(err(new UserError({})));
sandbox.stub(envUtil, "readEnv").resolves(ok({}));
Expand Down

0 comments on commit ec8c9bc

Please sign in to comment.