0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-24 22:46:02 -05:00

fix: test imports

This commit is contained in:
bholmesdev 2024-02-27 13:12:50 -05:00
parent 9c0139b86e
commit cbc4dc58c3
3 changed files with 22 additions and 22 deletions

View file

@ -4,16 +4,16 @@ import {
getCollectionChangeQueries, getCollectionChangeQueries,
getMigrationQueries, getMigrationQueries,
} from '../../dist/core/cli/migration-queries.js'; } from '../../dist/core/cli/migration-queries.js';
import { getCreateTableQuery } from '../../dist/core/queries.js'; import { getCreateTableQuery } from '../../dist/runtime/queries.js';
import { collectionSchema, column, defineReadableTable } from '../../dist/core/types.js'; import { tableSchema, column, defineTable } from '../../dist/core/types.js';
import { NOW } from '../../dist/runtime/index.js'; import { NOW } from '../../dist/runtime/index.js';
const COLLECTION_NAME = 'Users'; const COLLECTION_NAME = 'Users';
// `parse` to resolve schema transformations // `parse` to resolve schema transformations
// ex. convert column.date() to ISO strings // ex. convert column.date() to ISO strings
const userInitial = collectionSchema.parse( const userInitial = tableSchema.parse(
defineReadableTable({ defineTable({
columns: { columns: {
name: column.text(), name: column.text(),
age: column.number(), age: column.number(),
@ -95,14 +95,14 @@ describe('column queries', () => {
}); });
it('should be empty when type updated to same underlying SQL type', async () => { it('should be empty when type updated to same underlying SQL type', async () => {
const blogInitial = collectionSchema.parse({ const blogInitial = tableSchema.parse({
...userInitial, ...userInitial,
columns: { columns: {
title: column.text(), title: column.text(),
draft: column.boolean(), draft: column.boolean(),
}, },
}); });
const blogFinal = collectionSchema.parse({ const blogFinal = tableSchema.parse({
...userInitial, ...userInitial,
columns: { columns: {
...blogInitial.columns, ...blogInitial.columns,
@ -114,7 +114,7 @@ describe('column queries', () => {
}); });
it('should respect user primary key without adding a hidden id', async () => { it('should respect user primary key without adding a hidden id', async () => {
const user = collectionSchema.parse({ const user = tableSchema.parse({
...userInitial, ...userInitial,
columns: { columns: {
...userInitial.columns, ...userInitial.columns,
@ -122,7 +122,7 @@ describe('column queries', () => {
}, },
}); });
const userFinal = collectionSchema.parse({ const userFinal = tableSchema.parse({
...user, ...user,
columns: { columns: {
...user.columns, ...user.columns,
@ -287,7 +287,7 @@ describe('column queries', () => {
}); });
it('when updating to a runtime default', async () => { it('when updating to a runtime default', async () => {
const initial = collectionSchema.parse({ const initial = tableSchema.parse({
...userInitial, ...userInitial,
columns: { columns: {
...userInitial.columns, ...userInitial.columns,
@ -295,7 +295,7 @@ describe('column queries', () => {
}, },
}); });
const userFinal = collectionSchema.parse({ const userFinal = tableSchema.parse({
...initial, ...initial,
columns: { columns: {
...initial.columns, ...initial.columns,
@ -317,7 +317,7 @@ describe('column queries', () => {
}); });
it('when adding a column with a runtime default', async () => { it('when adding a column with a runtime default', async () => {
const userFinal = collectionSchema.parse({ const userFinal = tableSchema.parse({
...userInitial, ...userInitial,
columns: { columns: {
...userInitial.columns, ...userInitial.columns,
@ -407,7 +407,7 @@ describe('column queries', () => {
it('when adding a required column with default', async () => { it('when adding a required column with default', async () => {
const defaultDate = new Date('2023-01-01'); const defaultDate = new Date('2023-01-01');
const userFinal = collectionSchema.parse({ const userFinal = tableSchema.parse({
...userInitial, ...userInitial,
columns: { columns: {
...userInitial.columns, ...userInitial.columns,

View file

@ -1,9 +1,9 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { describe, it } from 'mocha'; import { describe, it } from 'mocha';
import { getCollectionChangeQueries } from '../../dist/core/cli/migration-queries.js'; import { getCollectionChangeQueries } from '../../dist/core/cli/migration-queries.js';
import { collectionSchema, column } from '../../dist/core/types.js'; import { tableSchema, column } from '../../dist/core/types.js';
const userInitial = collectionSchema.parse({ const userInitial = tableSchema.parse({
columns: { columns: {
name: column.text(), name: column.text(),
age: column.number(), age: column.number(),

View file

@ -1,9 +1,9 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { describe, it } from 'mocha'; import { describe, it } from 'mocha';
import { getCollectionChangeQueries } from '../../dist/core/cli/migration-queries.js'; import { getCollectionChangeQueries } from '../../dist/core/cli/migration-queries.js';
import { column, defineReadableTable, tablesSchema } from '../../dist/core/types.js'; import { column, defineTable, tablesSchema } from '../../dist/core/types.js';
const BaseUser = defineReadableTable({ const BaseUser = defineTable({
columns: { columns: {
id: column.number({ primaryKey: true }), id: column.number({ primaryKey: true }),
name: column.text(), name: column.text(),
@ -13,7 +13,7 @@ const BaseUser = defineReadableTable({
}, },
}); });
const BaseSentBox = defineReadableTable({ const BaseSentBox = defineTable({
columns: { columns: {
to: column.number(), to: column.number(),
toName: column.text(), toName: column.text(),
@ -58,7 +58,7 @@ describe('reference queries', () => {
it('adds references with lossless table recreate', async () => { it('adds references with lossless table recreate', async () => {
const { SentBox: Initial } = resolveReferences(); const { SentBox: Initial } = resolveReferences();
const { SentBox: Final } = resolveReferences({ const { SentBox: Final } = resolveReferences({
SentBox: defineReadableTable({ SentBox: defineTable({
columns: { columns: {
...BaseSentBox.columns, ...BaseSentBox.columns,
to: column.number({ references: () => BaseUser.columns.id }), to: column.number({ references: () => BaseUser.columns.id }),
@ -82,7 +82,7 @@ describe('reference queries', () => {
it('removes references with lossless table recreate', async () => { it('removes references with lossless table recreate', async () => {
const { SentBox: Initial } = resolveReferences({ const { SentBox: Initial } = resolveReferences({
SentBox: defineReadableTable({ SentBox: defineTable({
columns: { columns: {
...BaseSentBox.columns, ...BaseSentBox.columns,
to: column.number({ references: () => BaseUser.columns.id }), to: column.number({ references: () => BaseUser.columns.id }),
@ -108,7 +108,7 @@ describe('reference queries', () => {
it('does not use ADD COLUMN when adding optional column with reference', async () => { it('does not use ADD COLUMN when adding optional column with reference', async () => {
const { SentBox: Initial } = resolveReferences(); const { SentBox: Initial } = resolveReferences();
const { SentBox: Final } = resolveReferences({ const { SentBox: Final } = resolveReferences({
SentBox: defineReadableTable({ SentBox: defineTable({
columns: { columns: {
...BaseSentBox.columns, ...BaseSentBox.columns,
from: column.number({ references: () => BaseUser.columns.id, optional: true }), from: column.number({ references: () => BaseUser.columns.id, optional: true }),
@ -131,13 +131,13 @@ describe('reference queries', () => {
it('adds and updates foreign key with lossless table recreate', async () => { it('adds and updates foreign key with lossless table recreate', async () => {
const { SentBox: InitialWithoutFK } = resolveReferences(); const { SentBox: InitialWithoutFK } = resolveReferences();
const { SentBox: InitialWithDifferentFK } = resolveReferences({ const { SentBox: InitialWithDifferentFK } = resolveReferences({
SentBox: defineReadableTable({ SentBox: defineTable({
...BaseSentBox, ...BaseSentBox,
foreignKeys: [{ columns: ['to'], references: () => [BaseUser.columns.id] }], foreignKeys: [{ columns: ['to'], references: () => [BaseUser.columns.id] }],
}), }),
}); });
const { SentBox: Final } = resolveReferences({ const { SentBox: Final } = resolveReferences({
SentBox: defineReadableTable({ SentBox: defineTable({
...BaseSentBox, ...BaseSentBox,
foreignKeys: [ foreignKeys: [
{ {