Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure lambdas from parameter store #658

Merged
merged 5 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions babel-node-modules-opt-in.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Patterns matching node_modules dependencies that Babel and Jest should transform
@grrr/cookie-consent
@grrr/utils
nanoid
jsdom
strip-indent
normalize-url
text-fragments-polyfill
approx-string-match
is-absolute-url
# Because there is a node_modules in this path, we must we must also match it separately
@smithy/middleware-retry/node_modules/uuid/dist/esm-browser
# (match the included node_modules path separately)
uuid/dist/esm-browser
12 changes: 10 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
var fs = require("fs");
var ignores = fs
.readFileSync(__dirname + "/babel-node-modules-opt-in.txt", "utf8")
.replace(/#.*\n/g, "")
.split("\n")
.filter(Boolean)
.join("|");

module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript",
],
ignore: [
new RegExp(
// What we add here should probably go into Jest's transformIgnorePatterns too.
"/node_modules/(?!(@grrr/cookie-consent|@grrr/utils|nanoid|jsdom|strip-indent|normalize-url|text-fragments-polyfill|approx-string-match|is-absolute-url))"
// Ignore node_modules except for specific packages we must transform.
"/node_modules/(?!(" + ignores + "))"
),
],
plugins: [
Expand Down
24 changes: 15 additions & 9 deletions howdju-service-common/lib/daos/AppearancesDao.test.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
import { Pool } from "pg";

import { utcNow } from "howdju-common";
import { mockLogger } from "howdju-test-common";

import { endPoolAndDropDb, initDb, makeTestDbConfig } from "@/util/testUtil";
import { Database, makePool } from "../database";
import {
endPoolAndDropDb,
initDb,
makeTestClientProvider,
makeTestDbConfig,
} from "@/util/testUtil";
import { Database, PoolClientProvider } from "../database";
import { makeTestProvider } from "@/initializers/TestProvider";
import TestHelper from "@/initializers/TestHelper";
import { AppearancesDao } from "./AppearancesDao";
import { utcNow } from "howdju-common";

const dbConfig = makeTestDbConfig();

describe("AppearancesDao", () => {
let dbName: string;
let pool: Pool;
let clientProvider: PoolClientProvider;
let database: Database;

let dao: AppearancesDao;
let testHelper: TestHelper;
beforeEach(async () => {
dbName = await initDb(dbConfig);

pool = makePool(mockLogger, { ...dbConfig, database: dbName });
database = new Database(mockLogger, pool);
clientProvider = makeTestClientProvider({
...dbConfig,
database: dbName,
});
database = new Database(mockLogger, clientProvider);

const provider = makeTestProvider(database);

dao = provider.appearancesDao;
testHelper = provider.testHelper;
});
afterEach(async () => {
await endPoolAndDropDb(pool, dbConfig, dbName);
await endPoolAndDropDb(clientProvider, dbConfig, dbName);
});

describe("createAppearanceReturningId", () => {
Expand Down
21 changes: 14 additions & 7 deletions howdju-service-common/lib/daos/JustificationsDao.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from "@jest/globals";
import { assign, omit, pick } from "lodash";
import moment from "moment";
import { Pool } from "pg";

import {
JustificationRef,
Expand All @@ -23,22 +22,27 @@ import {
} from "howdju-test-common";

import { JustificationsDao } from "./JustificationsDao";
import { endPoolAndDropDb, initDb, makeTestDbConfig } from "@/util/testUtil";
import {
endPoolAndDropDb,
initDb,
makeTestClientProvider,
makeTestDbConfig,
} from "@/util/testUtil";
import {
Database,
makePool,
PersorgsDao,
PropositionsDao,
StatementsService,
PropositionCompoundsService,
PoolClientProvider,
} from "..";
import { makeTestProvider } from "@/initializers/TestProvider";
import { CreateJustificationDataIn } from "./dataTypes";
import TestHelper from "@/initializers/TestHelper";

describe("JustificationsDao", () => {
const dbConfig = makeTestDbConfig();
let pool: Pool;
let clientProvider: PoolClientProvider;
let dao: JustificationsDao;
let dbName: string;
let statementsService: StatementsService;
Expand All @@ -49,8 +53,11 @@ describe("JustificationsDao", () => {
beforeEach(async () => {
dbName = await initDb(dbConfig);

pool = makePool(mockLogger, { ...dbConfig, database: dbName });
const database = new Database(mockLogger, pool);
clientProvider = makeTestClientProvider({
...dbConfig,
database: dbName,
});
const database = new Database(mockLogger, clientProvider);

const provider = makeTestProvider(database);

Expand All @@ -62,7 +69,7 @@ describe("JustificationsDao", () => {
propositionCompoundsService = provider.propositionCompoundsService;
});
afterEach(async () => {
await endPoolAndDropDb(pool, dbConfig, dbName);
await endPoolAndDropDb(clientProvider, dbConfig, dbName);
});

describe("createJustification", () => {
Expand Down
21 changes: 14 additions & 7 deletions howdju-service-common/lib/daos/MediaExcerptsDao.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Pool } from "pg";
import { merge, parseInt, toString } from "lodash";

import { MomentConstructor, normalizeUrl, utcNow } from "howdju-common";
import { expectToBeSameMomentDeep, mockLogger } from "howdju-test-common";

import { endPoolAndDropDb, initDb, makeTestDbConfig } from "@/util/testUtil";
import { Database, makePool } from "../database";
import {
endPoolAndDropDb,
initDb,
makeTestClientProvider,
makeTestDbConfig,
} from "@/util/testUtil";
import { Database, PoolClientProvider } from "../database";
import { MediaExcerptsDao, SourcesDao, UrlsDao } from "../daos";
import { makeTestProvider } from "@/initializers/TestProvider";
import TestHelper from "@/initializers/TestHelper";
Expand All @@ -15,7 +19,7 @@ const dbConfig = makeTestDbConfig();

describe("MediaExcerptsDao", () => {
let dbName: string;
let pool: Pool;
let clientProvider: PoolClientProvider;
let database: Database;

let dao: MediaExcerptsDao;
Expand All @@ -26,8 +30,11 @@ describe("MediaExcerptsDao", () => {
beforeEach(async () => {
dbName = await initDb(dbConfig);

pool = makePool(mockLogger, { ...dbConfig, database: dbName });
database = new Database(mockLogger, pool);
clientProvider = makeTestClientProvider({
...dbConfig,
database: dbName,
});
database = new Database(mockLogger, clientProvider);

const provider = makeTestProvider(database);

Expand All @@ -38,7 +45,7 @@ describe("MediaExcerptsDao", () => {
testHelper = provider.testHelper;
});
afterEach(async () => {
await endPoolAndDropDb(pool, dbConfig, dbName);
await endPoolAndDropDb(clientProvider, dbConfig, dbName);
});

describe("readMediaExcerptForId", () => {
Expand Down
22 changes: 14 additions & 8 deletions howdju-service-common/lib/daos/PersorgsDao.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Pool } from "pg";

import { mockLogger } from "howdju-test-common";

import { endPoolAndDropDb, initDb, makeTestDbConfig } from "@/util/testUtil";
import { Database, makePool } from "../database";
import {
endPoolAndDropDb,
initDb,
makeTestClientProvider,
makeTestDbConfig,
} from "@/util/testUtil";
import { Database, PoolClientProvider } from "../database";
import { makeTestProvider } from "@/initializers/TestProvider";
import TestHelper from "@/initializers/TestHelper";
import { PersorgsDao } from "./PersorgsDao";
Expand All @@ -13,24 +16,27 @@ const dbConfig = makeTestDbConfig();

describe("PersorgsDao", () => {
let dbName: string;
let pool: Pool;
let clientProvider: PoolClientProvider;
let database: Database;

let dao: PersorgsDao;
let testHelper: TestHelper;
beforeEach(async () => {
dbName = await initDb(dbConfig);

pool = makePool(mockLogger, { ...dbConfig, database: dbName });
database = new Database(mockLogger, pool);
clientProvider = makeTestClientProvider({
...dbConfig,
database: dbName,
});
database = new Database(mockLogger, clientProvider);

const provider = makeTestProvider(database);

dao = provider.persorgsDao;
testHelper = provider.testHelper;
});
afterEach(async () => {
await endPoolAndDropDb(pool, dbConfig, dbName);
await endPoolAndDropDb(clientProvider, dbConfig, dbName);
});

describe("readEquivalentPersorg", () => {
Expand Down
22 changes: 14 additions & 8 deletions howdju-service-common/lib/daos/PropositionsDao.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Pool } from "pg";

import { CreateProposition, utcNow } from "howdju-common";
import { expectToBeSameMomentDeep, mockLogger } from "howdju-test-common";

import { endPoolAndDropDb, initDb, makeTestDbConfig } from "@/util/testUtil";
import { Database, makePool } from "../database";
import {
endPoolAndDropDb,
initDb,
makeTestClientProvider,
makeTestDbConfig,
} from "@/util/testUtil";
import { Database, PoolClientProvider } from "../database";
import { PropositionsDao } from "../daos";
import { makeTestProvider } from "@/initializers/TestProvider";
import TestHelper from "@/initializers/TestHelper";
Expand All @@ -13,23 +16,26 @@ const dbConfig = makeTestDbConfig();

describe("PropositionsDao", () => {
let dbName: string;
let pool: Pool;
let clientProvider: PoolClientProvider;

let dao: PropositionsDao;
let testHelper: TestHelper;
beforeEach(async () => {
dbName = await initDb(dbConfig);

pool = makePool(mockLogger, { ...dbConfig, database: dbName });
const database = new Database(mockLogger, pool);
clientProvider = makeTestClientProvider({
...dbConfig,
database: dbName,
});
const database = new Database(mockLogger, clientProvider);

const provider = makeTestProvider(database);

dao = provider.propositionsDao;
testHelper = provider.testHelper;
});
afterEach(async () => {
await endPoolAndDropDb(pool, dbConfig, dbName);
await endPoolAndDropDb(clientProvider, dbConfig, dbName);
});

describe("readPropositionByText", () => {
Expand Down
22 changes: 14 additions & 8 deletions howdju-service-common/lib/daos/StatementsDao.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { Pool } from "pg";

import { CreatePersorg, CreateProposition, utcNow } from "howdju-common";
import { mockLogger } from "howdju-test-common";

import { StatementsDao } from "./StatementsDao";
import { Database, makePool } from "../database";
import { Database, PoolClientProvider } from "../database";
import TestHelper from "@/initializers/TestHelper";
import { endPoolAndDropDb, initDb, makeTestDbConfig } from "@/util/testUtil";
import {
endPoolAndDropDb,
initDb,
makeTestClientProvider,
makeTestDbConfig,
} from "@/util/testUtil";
import { makeTestProvider } from "@/initializers/TestProvider";
import { PersorgsService, PropositionsService } from "..";

const dbConfig = makeTestDbConfig();

describe("StatementsDao", () => {
let dbName: string;
let pool: Pool;
let clientProvider: PoolClientProvider;
let database: Database;

let dao: StatementsDao;
Expand All @@ -24,8 +27,11 @@ describe("StatementsDao", () => {
beforeEach(async () => {
dbName = await initDb(dbConfig);

pool = makePool(mockLogger, { ...dbConfig, database: dbName });
database = new Database(mockLogger, pool);
clientProvider = makeTestClientProvider({
...dbConfig,
database: dbName,
});
database = new Database(mockLogger, clientProvider);

const provider = makeTestProvider(database);

Expand All @@ -35,7 +41,7 @@ describe("StatementsDao", () => {
testHelper = provider.testHelper;
});
afterEach(async () => {
await endPoolAndDropDb(pool, dbConfig, dbName);
await endPoolAndDropDb(clientProvider, dbConfig, dbName);
});
describe("readStatementForId", () => {
test("reads a statement for an ID", async () => {
Expand Down
Loading
Loading