Skip to content

Commit

Permalink
chore: update branch from main
Browse files Browse the repository at this point in the history
  • Loading branch information
p5quared committed Oct 7, 2024
1 parent 6589a44 commit c24617c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { FieldMap } from '../../../utils/sql-crudl-helper';

export const coffeeQueueFieldMap: FieldMap = {
orderNumber: true,
order: true,
customer: true,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type CoffeeQueue @model @refersTo(name: "e2e_test_coffee_queue") {
orderNumber: Int! @primaryKey @default
order: String!
customer: String
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import * as path from 'path';
import * as fs from 'fs-extra';
import { ImportedRDSType } from '@aws-amplify/graphql-transformer-core';
import AWSAppSyncClient, { AUTH_TYPE } from 'aws-appsync';
import { createNewProjectDir, deleteProjectDir, getRDSTableNamePrefix } from 'amplify-category-api-e2e-core';
import { initCDKProject, cdkDeploy, cdkDestroy } from '../commands';
import { SqlDatatabaseController } from '../sql-datatabase-controller';
import { CRUDLHelper } from '../utils/sql-crudl-helper';
import { ONE_MINUTE } from '../utils/duration-constants';
import { coffeeQueueFieldMap } from './schemas/sql-auto-increment/field-map';

export const testGraphQLAPIAutoIncrement = (
options: {
Expand All @@ -23,14 +25,8 @@ export const testGraphQLAPIAutoIncrement = (
// is allowed to omit the primary key field, and that the primary key
// we get back is the correct, db generated value.
// NOTE: Expects underlying orderNumber column to be a serial primary key in Postgres table
const amplifyGraphqlSchema = `
type CoffeeQueue @model @refersTo(name: "${getRDSTableNamePrefix()}coffee_queue") {
orderNumber: Int! @primaryKey @default
order: String!
customer: String
}
`;

const schemaPath = path.resolve(path.join(__dirname, '..', 'sql-tests-common', 'schemas', 'sql-auto-increment', 'schema.graphql'));
const schemaConfigString = fs.readFileSync(schemaPath).toString();
const { projFolderName, region, connectionConfigName, dbController } = options;
const templatePath = path.resolve(path.join(__dirname, '..', '__tests__', 'backends', 'sql-models'));

Expand All @@ -42,7 +38,7 @@ export const testGraphQLAPIAutoIncrement = (
beforeAll(async () => {
projRoot = await createNewProjectDir(projFolderName);
name = await initCDKProject(projRoot, templatePath);
dbController.writeDbDetails(projRoot, connectionConfigName, amplifyGraphqlSchema);
dbController.writeDbDetails(projRoot, connectionConfigName, schemaConfigString);
outputs = await cdkDeploy(projRoot, '--all', { postDeployWaitMs: ONE_MINUTE });
const { awsAppsyncApiEndpoint: apiEndpoint, awsAppsyncApiKey: apiKey } = outputs[name];

Expand All @@ -56,7 +52,7 @@ export const testGraphQLAPIAutoIncrement = (
},
});

coffeeQueueTableCRUDLHelper = new CRUDLHelper(appSyncClient, 'CoffeeQueue', 'CoffeeQueues', ['orderNumber', 'order', 'customer']);
coffeeQueueTableCRUDLHelper = new CRUDLHelper(appSyncClient, 'CoffeeQueue', 'CoffeeQueues', coffeeQueueFieldMap);
});

afterAll(async () => {
Expand Down

0 comments on commit c24617c

Please sign in to comment.