Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function throwInvalidContext(method: string, context: WorkerExecutionContext|SlicerExecutionContext): never {
const { assignment } = context.context;
const expected = assignment === Assignment.Worker ? Assignment.ExecutionController : Assignment.Worker;
const error = new Error(`${method} can only be run with assignment of "${expected}"`);
Error.captureStackTrace(error, throwInvalidContext);
throw error;
}
constructor(job: JobConfig, options: JobHarnessOptions) {
const context = new TestContext(`job-harness:${job.name}`);
context.assignment = options.assignment || Assignment.Worker;
const jobSchema = makeJobSchema(context);
const executionConfig = validateJobConfig(jobSchema, job) as ExecutionConfig;
this.context = makeExecutionContext({
context,
executionConfig
});
}