Fix tests.
This commit is contained in:
parent
2c3b3d03e1
commit
e0243b495c
|
@ -17,7 +17,6 @@ import {
|
||||||
basicWebhook,
|
basicWebhook,
|
||||||
} from "./structures"
|
} from "./structures"
|
||||||
import {
|
import {
|
||||||
auth,
|
|
||||||
cache,
|
cache,
|
||||||
constants,
|
constants,
|
||||||
context,
|
context,
|
||||||
|
@ -227,6 +226,13 @@ class TestConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
for (const key in newEnvVars) {
|
||||||
|
// @ts-ignore
|
||||||
|
delete env[key]
|
||||||
|
// @ts-ignore
|
||||||
|
delete coreEnv[key]
|
||||||
|
}
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(oldEnv)) {
|
for (const [key, value] of Object.entries(oldEnv)) {
|
||||||
env._set(key, value)
|
env._set(key, value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,12 @@ async function isSqsAvailable() {
|
||||||
await nodeFetch(coreEnv.COUCH_DB_SQL_URL, {
|
await nodeFetch(coreEnv.COUCH_DB_SQL_URL, {
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
})
|
})
|
||||||
|
sqsAvailable = true
|
||||||
|
return true
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sqsAvailable = false
|
sqsAvailable = false
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
sqsAvailable = true
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetch = async (ctx: Ctx) => {
|
export const fetch = async (ctx: Ctx) => {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { TestConfiguration } from "../../../../tests"
|
import { TestConfiguration } from "../../../../tests"
|
||||||
|
|
||||||
|
jest.unmock("node-fetch")
|
||||||
|
|
||||||
describe("/api/system/environment", () => {
|
describe("/api/system/environment", () => {
|
||||||
const config = new TestConfiguration()
|
const config = new TestConfiguration()
|
||||||
|
|
||||||
|
@ -29,10 +31,10 @@ describe("/api/system/environment", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns the expected environment for self hosters", async () => {
|
it("returns the expected environment for self hosters", async () => {
|
||||||
config.withEnv({ SELF_HOSTED: true }, async () => {
|
await config.withEnv({ SELF_HOSTED: true }, async () => {
|
||||||
const env = await config.api.environment.getEnvironment()
|
const env = await config.api.environment.getEnvironment()
|
||||||
expect(env.body).toEqual({
|
expect(env.body).toEqual({
|
||||||
cloud: true,
|
cloud: false,
|
||||||
disableAccountPortal: 0,
|
disableAccountPortal: 0,
|
||||||
isDev: false,
|
isDev: false,
|
||||||
multiTenancy: true,
|
multiTenancy: true,
|
||||||
|
|
|
@ -265,6 +265,13 @@ class TestConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
for (const key in newEnvVars) {
|
||||||
|
// @ts-ignore
|
||||||
|
delete env[key]
|
||||||
|
// @ts-ignore
|
||||||
|
delete coreEnv[key]
|
||||||
|
}
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(oldEnv)) {
|
for (const [key, value] of Object.entries(oldEnv)) {
|
||||||
env._set(key, value)
|
env._set(key, value)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue