Skip to content

Commit

Permalink
test: Updates all tests and codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobo committed Oct 30, 2024
1 parent 238b102 commit 5081c26
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 37 deletions.
40 changes: 34 additions & 6 deletions src/__generated__/config.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 4 additions & 14 deletions src/__generated__/openapi.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 4 additions & 10 deletions src/lib/taskless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,6 @@ export const taskless = (
// unblock http mock, letting requests through
setLoaded(true);
logger.trace("Unblocking HTTP wrapper");

// attach cleanup to process exit
process.on("exit", cleanup);
};

const cleanup = () => {
logger.trace("Performing cleanup");
// disable queue timer
clearTimeout(timer);
};

/**
Expand Down Expand Up @@ -515,7 +506,10 @@ export const autoload = (secret?: string, options?: InitOptions) => {
const t = taskless(secret, options);
t.logger.debug("Initialized Taskless");
try {
t.addDefaultPacks();
if (!secret) {
t.addDefaultPacks();
}

t.load()
.then(() => {
t.logger.debug("Taskless Autoloader ran successfully");
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export function isDefined<T>(value: T): value is NonNullable<T> {
export function isLogLevel(value: unknown): value is LogLevel {
return (
typeof value === "string" &&
["debug", "info", "warn", "error"].includes(value)
["trace", "debug", "info", "warn", "error"].includes(value)
);
}

export type MaybePromise<T> = T | Promise<T>;

type LogLevel = "debug" | "info" | "warn" | "error";
type LogLevel = "trace" | "debug" | "info" | "warn" | "error";

export type Logger = {
trace?: (message: string) => void;
Expand Down
10 changes: 5 additions & 5 deletions test/env.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("Taskless environment and importing (requires build)", () => {
const { stdout, stderr } = await execa({
preferLocal: true,
env: {
TASKLESS_LOG_LEVEL: "debug",
TASKLESS_LOG_LEVEL: "trace",
},
cwd: resolve(dirname(fileURLToPath(import.meta.url)), "../"),
})`node --import=./dist/index.js test/fixtures/end.js`;
Expand Down Expand Up @@ -70,7 +70,7 @@ describe("Taskless environment and importing (requires build)", () => {
const { stdout, stderr } = await execa({
preferLocal: true,
env: {
TASKLESS_LOG_LEVEL: "debug",
TASKLESS_LOG_LEVEL: "trace",
TASKLESS_API_KEY: "test",
TASKLESS_OPTIONS,
},
Expand All @@ -79,16 +79,16 @@ describe("Taskless environment and importing (requires build)", () => {

expect(stdout).toMatch(/initialized taskless/i);
expect(stdout).toMatch(/taskless autoloader ran successfully/i);
expect(stdout).toMatch(/performing cleanup/i);
// console.log(stdout);
expect(stdout).toMatch(/shutting down taskless/i);

expect(eventListener, "Mock event server was called").toBeCalledTimes(1);
});

test("No network and no logging is an error", async ({ expect }) => {
const { stdout, stderr } = await execa({
preferLocal: true,
env: {
TASKLESS_LOG_LEVEL: "debug",
TASKLESS_LOG_LEVEL: "trace",
TASKLESS_OPTIONS: "network=false;logging=false",
},
cwd: resolve(dirname(fileURLToPath(import.meta.url)), "../"),
Expand Down

0 comments on commit 5081c26

Please sign in to comment.