Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
chore: fix test command (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Sep 9, 2024
1 parent 214df69 commit b15e4b3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
14 changes: 7 additions & 7 deletions packages/backend/cli/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { Project } from "../../toolchain/project/mod.ts";
import { migrateModeSchema } from "../util.ts";

export const optsSchema = z.object({
watch: z.boolean().default(false).optional(),
runtime: z.enum([Runtime.Deno, Runtime.CloudflareWorkersPlatforms]).default(Runtime.Deno).optional(),
outputFormat: z.enum([Format.Native, Format.Bundled]).optional(),
dbDriver: z.enum([DbDriver.NodePostgres, DbDriver.NeonServerless, DbDriver.CloudflareHyperdrive]).optional(),
migrate: z.boolean().default(true).optional(),
migrateMode: migrateModeSchema.default(MigrateMode.Generate).optional(),
strictSchemas: z.boolean().default(true).optional(),
watch: z.boolean().default(false).nullable(),
runtime: z.enum([Runtime.Deno, Runtime.CloudflareWorkersPlatforms]).default(Runtime.Deno).nullable(),
outputFormat: z.enum([Format.Native, Format.Bundled]).nullable(),
dbDriver: z.enum([DbDriver.NodePostgres, DbDriver.NeonServerless, DbDriver.CloudflareHyperdrive]).nullable(),
migrate: z.boolean().default(true).nullable(),
migrateMode: migrateModeSchema.default(MigrateMode.Generate).nullable(),
strictSchemas: z.boolean().default(true).nullable(),
}).merge(globalOptsSchema);

type Opts = z.infer<typeof optsSchema>;
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/cli/commands/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { listSourceFiles } from "../../toolchain/project/mod.ts";
import { UserError } from "../../toolchain/error/mod.ts";

export const optsSchema = globalOptsSchema.extend({
check: z.boolean().optional(),
check: z.boolean().nullable(),
});

type Opts = z.infer<typeof optsSchema>;
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/cli/commands/module_add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { z } from "zod";

export const optsSchema = z.object({
moduleName: z.string(),
registry: z.string().optional(),
registry: z.string().nullable(),
}).merge(globalOptsSchema);

type Opts = z.infer<typeof optsSchema>;
Expand Down
10 changes: 9 additions & 1 deletion packages/backend/cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const optsSchema = z.object({
migrate: z.boolean().default(true),
migrateMode: migrateModeSchema.default(MigrateMode.Dev),
watch: z.boolean().default(false),
filter: z.string().optional(),
filter: z.string().nullable(),
modulesFilter: z.array(z.string()),
}).merge(globalOptsSchema);

Expand Down Expand Up @@ -59,6 +59,7 @@ export async function execute(opts: Opts) {

// Find test scripts
const testingModules = [];
let totalTestFiles = 0;
for (const module of project.modules.values()) {
// Filter modules
if (opts.modulesFilter.length == 0) {
Expand All @@ -76,6 +77,7 @@ export async function execute(opts: Opts) {
cwd: resolve(module.path, "tests"),
}))
.map((path) => resolve(module.path, "tests", path));
totalTestFiles += testPaths.length;
args.push(...testPaths);
}

Expand All @@ -84,6 +86,12 @@ export async function execute(opts: Opts) {
return;
}

if (totalTestFiles == 0) {
throw new UserError("No test files", {
suggest: "See 'rivet create test --help' to create a test."
});
}

// Run tests
info("Testing", testingModules.join(", "));
const cmd = await new Deno.Command("deno", {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/toolchain/template/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface MyRpcResponse {
}
export class Actor extends ActorBase<Input, State> {
public initialize(_input: Input) {
public initialize(_input: Input): State {
throw new Error("Unimplemented: ${moduleName}.${actorName}.initialize");
}
Expand Down

0 comments on commit b15e4b3

Please sign in to comment.