Skip to content

Commit

Permalink
Remove vitest fixture (#520)
Browse files Browse the repository at this point in the history
* Remove vitest-fixture

* Fix vitest cfg
  • Loading branch information
kristiandupont authored Apr 1, 2024
1 parent 7ab8e03 commit aeac683
Show file tree
Hide file tree
Showing 15 changed files with 219 additions and 205 deletions.
10 changes: 0 additions & 10 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"np": "9.2.0",
"testcontainers": "10.7.1",
"vitepress": "1.0.0-rc.44",
"vitest-fixture": "0.5.2",
"vue": "3.4.19"
},
"np": {},
Expand Down
12 changes: 9 additions & 3 deletions src/fetchExtensionItemIds.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { describe, expect } from "vitest";
import { describe, expect, it } from "vitest";

import fetchExtensionItemIds from "./fetchExtensionItemIds";
import { test } from "./tests/useSchema";
import useSchema from "./tests/useSchema";
import useTestKnex from "./tests/useTestKnex";

describe("fetchExtensionItemIds", () => {
const [getKnex] = useTestKnex();
useSchema(getKnex, "test");

// NOTE: be aware that this test depends on specifics of certain Postgres extensions.
// If it fails there is a chance that it's because the extensions themselves have changed,
// not necessarily the test.
test("it should fetch extension item ids", async ({ knex: [db] }) => {
it("should fetch extension item ids", async () => {
const db = getKnex();

await db.raw("create extension if not exists pg_trgm");
await db.raw("create extension if not exists pg_stat_statements");
await db.raw("create extension if not exists citext");
Expand Down
21 changes: 12 additions & 9 deletions src/kinds/extractCompositeType.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as R from "ramda";
import { describe, expect } from "vitest";
import { describe, expect, it } from "vitest";

import { test } from "../tests/useSchema";
import useSchema from "../tests/useSchema";
import useTestKnex from "../tests/useTestKnex";
import type {
CompositeTypeAttribute,
CompositeTypeDetails,
Expand All @@ -20,9 +21,11 @@ const makePgType = (
});

describe("extractCompositeType", () => {
test("it should extract simplified information", async ({
knex: [db, databaseName],
}) => {
const [getKnex, databaseName] = useTestKnex();
useSchema(getKnex, "test");

it("should extract simplified information", async () => {
const db = getKnex();
await db.raw("create type test.some_composite_type as (id integer)");

const result = await extractCompositeType(
Expand Down Expand Up @@ -105,7 +108,8 @@ describe("extractCompositeType", () => {
expect(result).toStrictEqual(expected);
});

test("it should fetch column comments", async ({ knex: [db] }) => {
it("should fetch column comments", async () => {
const db = getKnex();
await db.raw(
"create type test.some_composite_type as (id integer, name text)",
);
Expand All @@ -121,9 +125,8 @@ describe("extractCompositeType", () => {
expect(result.attributes[0].comment).toBe("id column");
});

test("it should handle domains, composite types, ranges and enums as well as arrays of those", async ({
knex: [db],
}) => {
it("should handle domains, composite types, ranges and enums as well as arrays of those", async () => {
const db = getKnex();
await db.raw("create domain test.some_domain as text");
await db.raw("create type test.some_composite as (id integer, name text)");
await db.raw("create type test.some_range as range(subtype=timestamptz)");
Expand Down
13 changes: 8 additions & 5 deletions src/kinds/extractDomain.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect } from "vitest";
import { describe, expect, it } from "vitest";

import { test } from "../tests/useSchema";
import useSchema from "../tests/useSchema";
import useTestKnex from "../tests/useTestKnex";
import type { DomainDetails } from "./extractDomain";
import extractDomain from "./extractDomain";
import type PgType from "./PgType";
Expand All @@ -13,9 +14,11 @@ const makePgType = (name: string, schemaName = "test"): PgType<"domain"> => ({
});

describe("extractDomain", () => {
test("it should extract simplified as well as full information_schema information", async ({
knex: [db, databaseName],
}) => {
const [getKnex, databaseName] = useTestKnex();
useSchema(getKnex, "test");

it("should extract simplified as well as full information_schema information", async () => {
const db = getKnex();
await db.raw("create domain test.some_domain as integer");

const result = await extractDomain(db, makePgType("some_domain"));
Expand Down
11 changes: 8 additions & 3 deletions src/kinds/extractEnum.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect } from "vitest";
import { describe, expect, it } from "vitest";

import { test } from "../tests/useSchema";
import useSchema from "../tests/useSchema";
import useTestKnex from "../tests/useTestKnex";
import type { EnumDetails } from "./extractEnum";
import extractEnum from "./extractEnum";
import type PgType from "./PgType";
Expand All @@ -13,7 +14,11 @@ const makePgType = (name: string, schemaName = "test"): PgType<"enum"> => ({
});

describe("extractEnum", () => {
test("it should extract enum values", async ({ knex: [db] }) => {
const [getKnex] = useTestKnex();
useSchema(getKnex, "test");

it("should extract enum values", async () => {
const db = getKnex();
await db.raw("create type test.some_enum as enum('a', 'b', 'c')");

const result = await extractEnum(db, makePgType("some_enum"));
Expand Down
21 changes: 12 additions & 9 deletions src/kinds/extractMaterializedView.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as R from "ramda";
import { describe, expect } from "vitest";
import { describe, expect, it } from "vitest";

import { test } from "../tests/useSchema";
import useSchema from "../tests/useSchema";
import useTestKnex from "../tests/useTestKnex";
import type {
MaterializedViewColumn,
MaterializedViewDetails,
Expand All @@ -20,9 +21,11 @@ const makePgType = (
});

describe("extractMaterializedView", () => {
test("it should extract simplified information", async ({
knex: [db, databaseName],
}) => {
const [getKnex, databaseName] = useTestKnex();
useSchema(getKnex, "test");

it("should extract simplified information", async () => {
const db = getKnex();
await db.raw(
"create materialized view test.some_materialized_view as select 1 as id",
);
Expand Down Expand Up @@ -120,7 +123,8 @@ describe("extractMaterializedView", () => {
expect(result).toStrictEqual(expected);
});

test("it should fetch column comments", async ({ knex: [db] }) => {
it("should fetch column comments", async () => {
const db = getKnex();
await db.raw(
"create materialized view test.some_materialized_view as select 1 as id",
);
Expand All @@ -136,9 +140,8 @@ describe("extractMaterializedView", () => {
expect(result.columns[0].comment).toBe("id column");
});

test("it should handle domains, composite types, ranges and enums as well as arrays of those", async ({
knex: [db],
}) => {
it("should handle domains, composite types, ranges and enums as well as arrays of those", async () => {
const db = getKnex();
await db.raw("create domain test.some_domain as text");
await db.raw("create type test.some_composite as (id integer, name text)");
await db.raw("create type test.some_range as range(subtype=timestamptz)");
Expand Down
11 changes: 8 additions & 3 deletions src/kinds/extractRange.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect } from "vitest";
import { describe, expect, it } from "vitest";

import { test } from "../tests/useSchema";
import useSchema from "../tests/useSchema";
import useTestKnex from "../tests/useTestKnex";
import type { RangeDetails } from "./extractRange";
import extractRange from "./extractRange";
import type PgType from "./PgType";
Expand All @@ -13,7 +14,11 @@ const makePgType = (name: string, schemaName = "test"): PgType<"range"> => ({
});

describe("extractRange", () => {
test("it should extract range values", async ({ knex: [db] }) => {
const [getKnex] = useTestKnex();
useSchema(getKnex, "test");

it("should extract range values", async () => {
const db = getKnex();
await db.raw("create type test.some_range as range(subtype=timestamptz)");

const result = await extractRange(db, makePgType("some_range"));
Expand Down
Loading

0 comments on commit aeac683

Please sign in to comment.