Skip to content

Commit e28cbac

Browse files
committed
Test that getJobUUID calls exportVariable
1 parent 60834a0 commit e28cbac

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

lib/entry-points.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy-action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ async function run(startedAt: Date) {
4141
let language: BuiltInLanguage | undefined;
4242

4343
try {
44-
const action: ActionState<["Logger", "Env"]> = {
44+
const action: ActionState<["Logger", "Env", "Actions"]> = {
4545
logger,
4646
env: new Env(process.env),
47+
actions: actionsUtil.getActionsEnv(),
4748
};
4849

4950
// Create a unique identifier for this run.

src/status-report.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,22 @@ import { BuildMode, ConfigurationError, withTmpDir, wrapError } from "./util";
2929
setupTests(test);
3030

3131
test("getJobUUID - generates valid UUIDs", async (t) => {
32+
const exportVariableStub: sinon.SinonStub<[string, string], void> =
33+
sinon.stub();
34+
3235
await callee(getJobUUID)
3336
.withArgs()
37+
.withActions((env) => {
38+
env.exportVariable = exportVariableStub;
39+
})
3440
.logs(t, "Job run UUID is ")
35-
.passes((val) => t.true(uuid.validate(val)));
41+
.passes((val) => {
42+
t.true(uuid.validate(val));
43+
44+
const calls = exportVariableStub.getCalls();
45+
t.is(calls.length, 1);
46+
t.deepEqual(calls[0].args, [EnvVar.JOB_RUN_UUID, val]);
47+
});
3648
});
3749

3850
test("getJobUUID - retrieves existing job UUIDs", async (t) => {

src/status-report.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export function getDisplayActionName(actionName: ActionName): string {
6666
* environment and returns it.
6767
* If a new UUID is generated, it is also exported as an environment variable.
6868
*/
69-
export function getJobUUID(action: ActionState<["Logger", "ReadOnlyEnv"]>) {
69+
export function getJobUUID(
70+
action: ActionState<["Logger", "ReadOnlyEnv", "Actions"]>,
71+
) {
7072
// Check if we already have a UUID for the analysis and return it if so.
7173
const existingJobRunUuid = action.env.getOptional(EnvVar.JOB_RUN_UUID);
7274

@@ -79,7 +81,7 @@ export function getJobUUID(action: ActionState<["Logger", "ReadOnlyEnv"]>) {
7981
const jobRunUuid = uuid.v4();
8082
action.logger.info(`Job run UUID is ${jobRunUuid}.`);
8183

82-
core.exportVariable(EnvVar.JOB_RUN_UUID, jobRunUuid);
84+
action.actions.exportVariable(EnvVar.JOB_RUN_UUID, jobRunUuid);
8385
return jobRunUuid;
8486
}
8587

0 commit comments

Comments
 (0)