Fix local test port
Test / test (push) Successful in 59s
Details
Test / test (push) Successful in 59s
Details
This commit is contained in:
parent
be55d46391
commit
a719706dff
|
|
@ -7,8 +7,6 @@ import {
|
|||
updateSubscription,
|
||||
} from "./subscription"
|
||||
|
||||
import { exec } from "child_process"
|
||||
|
||||
const pushSubscription1 = {
|
||||
endpoint: "https://updates.push.services.mozilla.com/wpush/v2/aaaaaaa",
|
||||
expirationTime: null,
|
||||
|
|
@ -28,96 +26,78 @@ const pushSubscription2 = {
|
|||
}
|
||||
|
||||
jest.mock("./settings", () => ({
|
||||
port: 5432,
|
||||
port: process.env.POSTGRES_PORT,
|
||||
user: "postgres",
|
||||
password: process.env.POSTGRES_PASSWORD,
|
||||
database: "test",
|
||||
host: process.env.POSTGRES_HOST ?? "localhost",
|
||||
host: process.env.POSTGRES_HOST,
|
||||
}))
|
||||
|
||||
describe("subscriptions", () => {
|
||||
test("Does it run", () => {
|
||||
console.log("WHOAH")
|
||||
expect(true).toBeTruthy()
|
||||
})
|
||||
|
||||
beforeAll(async () => {
|
||||
console.log("HEY WTF MAN")
|
||||
try {
|
||||
await resetDbInstance()
|
||||
} catch (error) {
|
||||
console.log("Something has exploded")
|
||||
fail(error)
|
||||
}
|
||||
await resetDbInstance()
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
exec("docker ps", (_, out) => console.log(out))
|
||||
exec("ls /home", (_, out) => console.log(out))
|
||||
await migrateToLatest()
|
||||
} catch (error) {
|
||||
console.log("Something has exploded in migration")
|
||||
fail(error)
|
||||
}
|
||||
await migrateToLatest()
|
||||
})
|
||||
|
||||
// afterEach(async () => {
|
||||
// await resetAll()
|
||||
// })
|
||||
afterEach(async () => {
|
||||
await resetAll()
|
||||
})
|
||||
|
||||
// afterAll(async () => {
|
||||
// await db.destroy()
|
||||
// })
|
||||
afterAll(async () => {
|
||||
await db.destroy()
|
||||
})
|
||||
|
||||
// test("createSubscription", async () => {
|
||||
// const { id } = await createSubscription(pushSubscription1)
|
||||
test("createSubscription", async () => {
|
||||
const { id } = await createSubscription(pushSubscription1)
|
||||
|
||||
// const subscription = (await db
|
||||
// .selectFrom("subscription")
|
||||
// .selectAll()
|
||||
// .where("id", "=", id)
|
||||
// .executeTakeFirst()) as Subscription
|
||||
const subscription = (await db
|
||||
.selectFrom("subscription")
|
||||
.selectAll()
|
||||
.where("id", "=", id)
|
||||
.executeTakeFirst()) as Subscription
|
||||
|
||||
// expect(subscription).toEqual({
|
||||
// id,
|
||||
// subscription: pushSubscription1,
|
||||
// })
|
||||
// })
|
||||
expect(subscription).toEqual({
|
||||
id,
|
||||
subscription: pushSubscription1,
|
||||
})
|
||||
})
|
||||
|
||||
// test("updateSubscription", async () => {
|
||||
// const { id } = (await db
|
||||
// .insertInto("subscription")
|
||||
// .values({ subscription: JSON.stringify(pushSubscription1), id: 50 })
|
||||
// .returning("id")
|
||||
// .executeTakeFirst())!
|
||||
test("updateSubscription", async () => {
|
||||
const { id } = (await db
|
||||
.insertInto("subscription")
|
||||
.values({ subscription: JSON.stringify(pushSubscription1), id: 50 })
|
||||
.returning("id")
|
||||
.executeTakeFirst())!
|
||||
|
||||
// await updateSubscription(pushSubscription2, id)
|
||||
await updateSubscription(pushSubscription2, id)
|
||||
|
||||
// const updated = (await db
|
||||
// .selectFrom("subscription")
|
||||
// .selectAll()
|
||||
// .where("id", "=", id)
|
||||
// .executeTakeFirst()) as Subscription
|
||||
const updated = (await db
|
||||
.selectFrom("subscription")
|
||||
.selectAll()
|
||||
.where("id", "=", id)
|
||||
.executeTakeFirst()) as Subscription
|
||||
|
||||
// expect(updated).toEqual({
|
||||
// id,
|
||||
// subscription: pushSubscription2,
|
||||
// })
|
||||
// })
|
||||
expect(updated).toEqual({
|
||||
id,
|
||||
subscription: pushSubscription2,
|
||||
})
|
||||
})
|
||||
|
||||
// test("getSubscription", async () => {
|
||||
// const { id } = (await db
|
||||
// .insertInto("subscription")
|
||||
// .values({ subscription: JSON.stringify(pushSubscription1), id: 5000 })
|
||||
// .returning("id")
|
||||
// .executeTakeFirst())!
|
||||
test("getSubscription", async () => {
|
||||
const { id } = (await db
|
||||
.insertInto("subscription")
|
||||
.values({ subscription: JSON.stringify(pushSubscription1), id: 5000 })
|
||||
.returning("id")
|
||||
.executeTakeFirst())!
|
||||
|
||||
// const got = await getSubscription(id)
|
||||
const got = await getSubscription(id)
|
||||
|
||||
// expect(got).toEqual({
|
||||
// subscription: pushSubscription1,
|
||||
// id: 5000,
|
||||
// })
|
||||
// })
|
||||
expect(got).toEqual({
|
||||
subscription: pushSubscription1,
|
||||
id: 5000,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue