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:
parent
9c0139b86e
commit
cbc4dc58c3
3 changed files with 22 additions and 22 deletions
|
@ -4,16 +4,16 @@ import {
|
|||
getCollectionChangeQueries,
|
||||
getMigrationQueries,
|
||||
} from '../../dist/core/cli/migration-queries.js';
|
||||
import { getCreateTableQuery } from '../../dist/core/queries.js';
|
||||
import { collectionSchema, column, defineReadableTable } from '../../dist/core/types.js';
|
||||
import { getCreateTableQuery } from '../../dist/runtime/queries.js';
|
||||
import { tableSchema, column, defineTable } from '../../dist/core/types.js';
|
||||
import { NOW } from '../../dist/runtime/index.js';
|
||||
|
||||
const COLLECTION_NAME = 'Users';
|
||||
|
||||
// `parse` to resolve schema transformations
|
||||
// ex. convert column.date() to ISO strings
|
||||
const userInitial = collectionSchema.parse(
|
||||
defineReadableTable({
|
||||
const userInitial = tableSchema.parse(
|
||||
defineTable({
|
||||
columns: {
|
||||
name: column.text(),
|
||||
age: column.number(),
|
||||
|
@ -95,14 +95,14 @@ describe('column queries', () => {
|
|||
});
|
||||
|
||||
it('should be empty when type updated to same underlying SQL type', async () => {
|
||||
const blogInitial = collectionSchema.parse({
|
||||
const blogInitial = tableSchema.parse({
|
||||
...userInitial,
|
||||
columns: {
|
||||
title: column.text(),
|
||||
draft: column.boolean(),
|
||||
},
|
||||
});
|
||||
const blogFinal = collectionSchema.parse({
|
||||
const blogFinal = tableSchema.parse({
|
||||
...userInitial,
|
||||
columns: {
|
||||
...blogInitial.columns,
|
||||
|
@ -114,7 +114,7 @@ describe('column queries', () => {
|
|||
});
|
||||
|
||||
it('should respect user primary key without adding a hidden id', async () => {
|
||||
const user = collectionSchema.parse({
|
||||
const user = tableSchema.parse({
|
||||
...userInitial,
|
||||
columns: {
|
||||
...userInitial.columns,
|
||||
|
@ -122,7 +122,7 @@ describe('column queries', () => {
|
|||
},
|
||||
});
|
||||
|
||||
const userFinal = collectionSchema.parse({
|
||||
const userFinal = tableSchema.parse({
|
||||
...user,
|
||||
columns: {
|
||||
...user.columns,
|
||||
|
@ -287,7 +287,7 @@ describe('column queries', () => {
|
|||
});
|
||||
|
||||
it('when updating to a runtime default', async () => {
|
||||
const initial = collectionSchema.parse({
|
||||
const initial = tableSchema.parse({
|
||||
...userInitial,
|
||||
columns: {
|
||||
...userInitial.columns,
|
||||
|
@ -295,7 +295,7 @@ describe('column queries', () => {
|
|||
},
|
||||
});
|
||||
|
||||
const userFinal = collectionSchema.parse({
|
||||
const userFinal = tableSchema.parse({
|
||||
...initial,
|
||||
columns: {
|
||||
...initial.columns,
|
||||
|
@ -317,7 +317,7 @@ describe('column queries', () => {
|
|||
});
|
||||
|
||||
it('when adding a column with a runtime default', async () => {
|
||||
const userFinal = collectionSchema.parse({
|
||||
const userFinal = tableSchema.parse({
|
||||
...userInitial,
|
||||
columns: {
|
||||
...userInitial.columns,
|
||||
|
@ -407,7 +407,7 @@ describe('column queries', () => {
|
|||
|
||||
it('when adding a required column with default', async () => {
|
||||
const defaultDate = new Date('2023-01-01');
|
||||
const userFinal = collectionSchema.parse({
|
||||
const userFinal = tableSchema.parse({
|
||||
...userInitial,
|
||||
columns: {
|
||||
...userInitial.columns,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { expect } from 'chai';
|
||||
import { describe, it } from 'mocha';
|
||||
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: {
|
||||
name: column.text(),
|
||||
age: column.number(),
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { expect } from 'chai';
|
||||
import { describe, it } from 'mocha';
|
||||
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: {
|
||||
id: column.number({ primaryKey: true }),
|
||||
name: column.text(),
|
||||
|
@ -13,7 +13,7 @@ const BaseUser = defineReadableTable({
|
|||
},
|
||||
});
|
||||
|
||||
const BaseSentBox = defineReadableTable({
|
||||
const BaseSentBox = defineTable({
|
||||
columns: {
|
||||
to: column.number(),
|
||||
toName: column.text(),
|
||||
|
@ -58,7 +58,7 @@ describe('reference queries', () => {
|
|||
it('adds references with lossless table recreate', async () => {
|
||||
const { SentBox: Initial } = resolveReferences();
|
||||
const { SentBox: Final } = resolveReferences({
|
||||
SentBox: defineReadableTable({
|
||||
SentBox: defineTable({
|
||||
columns: {
|
||||
...BaseSentBox.columns,
|
||||
to: column.number({ references: () => BaseUser.columns.id }),
|
||||
|
@ -82,7 +82,7 @@ describe('reference queries', () => {
|
|||
|
||||
it('removes references with lossless table recreate', async () => {
|
||||
const { SentBox: Initial } = resolveReferences({
|
||||
SentBox: defineReadableTable({
|
||||
SentBox: defineTable({
|
||||
columns: {
|
||||
...BaseSentBox.columns,
|
||||
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 () => {
|
||||
const { SentBox: Initial } = resolveReferences();
|
||||
const { SentBox: Final } = resolveReferences({
|
||||
SentBox: defineReadableTable({
|
||||
SentBox: defineTable({
|
||||
columns: {
|
||||
...BaseSentBox.columns,
|
||||
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 () => {
|
||||
const { SentBox: InitialWithoutFK } = resolveReferences();
|
||||
const { SentBox: InitialWithDifferentFK } = resolveReferences({
|
||||
SentBox: defineReadableTable({
|
||||
SentBox: defineTable({
|
||||
...BaseSentBox,
|
||||
foreignKeys: [{ columns: ['to'], references: () => [BaseUser.columns.id] }],
|
||||
}),
|
||||
});
|
||||
const { SentBox: Final } = resolveReferences({
|
||||
SentBox: defineReadableTable({
|
||||
SentBox: defineTable({
|
||||
...BaseSentBox,
|
||||
foreignKeys: [
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue