-
-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
65 additions
and
10 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/lib/features/change-request-access-service/sql-change-request-access-read-model.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import dbInit, { type ITestDb } from '../../../test/e2e/helpers/database-init'; | ||
import getLogger from '../../../test/fixtures/no-logger'; | ||
import { createChangeRequestAccessReadModel } from './createChangeRequestAccessReadModel'; | ||
import { createTestConfig } from '../../../test/config/test-config'; | ||
import type { IChangeRequestAccessReadModel } from './change-request-access-read-model'; | ||
|
||
let db: ITestDb; | ||
|
||
let readModel: IChangeRequestAccessReadModel; | ||
|
||
beforeAll(async () => { | ||
db = await dbInit('change_request_access_read_model', getLogger); | ||
|
||
const config = createTestConfig({ | ||
getLogger, | ||
}); | ||
|
||
readModel = createChangeRequestAccessReadModel(db.rawDatabase, config); | ||
}); | ||
|
||
afterAll(async () => { | ||
await db.destroy(); | ||
}); | ||
|
||
test(`Should indicate change request enabled status`, async () => { | ||
// no change requests | ||
const defaultStatus = | ||
await readModel.isChangeRequestsEnabledForProject('default'); | ||
expect(defaultStatus).toBe(false); | ||
|
||
// change request enabled in enabled environment | ||
await db.rawDatabase('change_request_settings').insert({ | ||
project: 'default', | ||
environment: 'default', | ||
required_approvals: 1, | ||
}); | ||
const enabledStatus = | ||
await readModel.isChangeRequestsEnabledForProject('default'); | ||
expect(enabledStatus).toBe(true); | ||
|
||
// change request enabled in disabled environment | ||
await db.stores.projectStore.deleteEnvironmentForProject( | ||
'default', | ||
'default', | ||
); | ||
const disabledStatus = | ||
await readModel.isChangeRequestsEnabledForProject('default'); | ||
expect(disabledStatus).toBe(false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters