Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updates to PartiQL scenarios
  • Loading branch information
brmur committed Dec 6, 2022
commit 9a35d8d53428edb70d2589629b22aa856e83d38c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DeleteCommand } from "@aws-sdk/lib-dynamodb";
import { describe, it, afterAll } from "vitest";
import { ddbDocClient } from "../libs/ddbDocClient.js";
import { main } from "../src/dynamodb_basics.js";
import { runScenario } from "../src/dynamodb_basics.js";

describe("dynamodb_basics#run", () => {
afterAll(async () => {
Expand All @@ -14,14 +14,17 @@ describe("dynamodb_basics#run", () => {
});

it("should successfully run", async () => {
await main(
"myNewTable",
"myMovieName",
2022,
"This Is the End",
2013,
200,
"A coder cracks code..."
await runScenario(
{
tableName: "myNewTable",
newMovieName: "myMovieName",
newMovieYear: 2022,
existingMovieName: "This Is the End",
existingMovieYear: 2013,
newMovieRank: 200,
newMoviePlot: "A coder cracks code...",
moviesPath: "../../../../../../resources/sample_files/movies.json",
}
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -265,19 +265,19 @@ const deleteTable = async (tableName) => {
};

export const runScenario = async ({
tableName,
newMovieName1,
newMovieYear1,
newMovieName2,
newMovieYear2,
existingMovieName1,
existingMovieYear1,
existingMovieName2,
existingMovieYear2,
newProducer1,
newProducer2,
moviesPath
}) => {
tableName,
newMovieName1,
newMovieYear1,
newMovieName2,
newMovieYear2,
existingMovieName1,
existingMovieYear1,
existingMovieName2,
existingMovieYear2,
newProducer1,
newProducer2,
moviesPath
}) => {
await createTable(tableName);
console.log(`Creating table named: ${tableName}`);
console.log(`\nTable created.`);
Expand Down Expand Up @@ -330,7 +330,7 @@ export const runScenario = async ({
console.log(`${tableName} deleted.`);
};

const main1 = async () => {
const main = async () => {
const args = {
tableName: "myNewTable",
newMovieName1: "myMovieName1",
Expand Down Expand Up @@ -366,5 +366,5 @@ const main1 = async () => {
}
};

export {main1};
export {main};
// snippet-end:[javascript.dynamodb_scenarios.partiQL_batch_basics]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {DeleteTableCommand} from "@aws-sdk/client-dynamodb";
import {describe, it, afterAll} from "vitest";
import {ddbDocClient} from "../../libs/ddbDocClient.js";
import {runScenario} from "../../src/partiQL_basics.js";

describe("partiQL_basics#run", () => {
afterAll(async () => {
const command = new DeleteTableCommand({TableName: "myNewTable"});
try {
await ddbDocClient.send(command);
} catch (err) {
console.error(err);
}
});

it("should successfully run", async () => {
await runScenario(
{
tableName: "myNewTable",
newMovieName: "myMovieName",
newMovieYear: 2022,
existingMovieName: "This Is the End",
existingMovieYear: 2013,
newProducer: "Amazon Movies",
moviesPath: "../../../../../../../resources/sample_files/movies.json",
}
);
})
});
Loading