Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Generator: Add failing test for type: "text" runtime type #1491

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/api/cms-api/src/generator/generate-crud.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
id: string = uuid();

@Property()
title: string;

Check failure on line 14 in packages/api/cms-api/src/generator/generate-crud.spec.ts

View workflow job for this annotation

GitHub Actions / Tests

GenerateCrud ► GenerateCrud resolver class should be a valid generated ts file ► GenerateCrud resolver class should be a valid generated ts file

Failed test found in: api/cms-api/junit.xml Error: Error: expect(received).rejects.toThrow()
Raw output
Error: expect(received).rejects.toThrow()

Received promise resolved instead of rejected
Resolved to value: undefined
    at expect (/home/runner/work/comet/comet/node_modules/.pnpm/expect@29.5.0/node_modules/expect/build/index.js:105:15)
    at /home/runner/work/comet/comet/packages/api/cms-api/src/generator/generate-crud.spec.ts:45:13
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/comet/comet/packages/api/cms-api/src/generator/generate-crud.spec.ts:14:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
}

@Entity()
Expand All @@ -23,7 +23,33 @@
foo: number;
}

@Entity()
export class TestEntityWithTextRuntimeType extends BaseEntity<TestEntityWithTextRuntimeType, "id"> {
@PrimaryKey({ type: "uuid" })
id: string = uuid();

@Property({ type: "text" })
title: string;
}

describe("GenerateCrud", () => {
describe("metadata validation", () => {
it("should throw an error for runtime type 'text'", async () => {
LazyMetadataStorage.load();
const orm = await MikroORM.init({
type: "postgresql",
dbName: "test-db",
entities: [TestEntityWithTextRuntimeType],
});

expect(async () => {
await generateCrud({ targetDirectory: __dirname }, orm.em.getMetadata().get("TestEntityWithTextRuntimeType"));
}).rejects.toThrow("Runtime type 'text' of property 'title' is not supported. Maybe you wanted to use 'columnType' instead?");

orm.close();
});
});

describe("resolver class", () => {
it("should be a valid generated ts file", async () => {
LazyMetadataStorage.load();
Expand Down
Loading