Skip to content

Commit cf3ab7d

Browse files
committed
test(ceph): update tests to use CEPH_REGION env variable
1 parent 3b7669a commit cf3ab7d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

apps/aurora-portal/src/server/Storage/cephProcedure.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ describe("cephProcedure", () => {
158158
describe("endpoint extraction", () => {
159159
beforeEach(() => {
160160
vi.clearAllMocks()
161+
// Set default CEPH_REGION for tests
162+
process.env.CEPH_REGION = "ceph-objectstore-ec-st1-qa-de-1"
161163
mockResolveEC2Credential.mockResolvedValue({
162164
credentialId: "cred-id",
163165
access: TEST_ACCESS,
@@ -207,6 +209,7 @@ describe("cephProcedure", () => {
207209
})
208210

209211
it("constructs standard region for non-qa-de-1 regions", async () => {
212+
process.env.CEPH_REGION = "ceph-objectstore-st1-eu-de-2"
210213
const ctx = createMockContext({ endpoint: TEST_CEPH_ENDPOINT_NO_SWIFT, region: "eu-de-2" })
211214
const caller = createCaller(ctx)
212215

@@ -221,6 +224,7 @@ describe("cephProcedure", () => {
221224
})
222225

223226
it("constructs QA region for qa-de-1 with ec prefix", async () => {
227+
process.env.CEPH_REGION = "ceph-objectstore-ec-st1-qa-de-1"
224228
const ctx = createMockContext({ endpoint: TEST_CEPH_ENDPOINT, region: "qa-de-1" })
225229
const caller = createCaller(ctx)
226230

@@ -238,6 +242,7 @@ describe("cephProcedure", () => {
238242
describe("error handling", () => {
239243
beforeEach(() => {
240244
vi.clearAllMocks()
245+
process.env.CEPH_REGION = "ceph-objectstore-ec-st1-qa-de-1"
241246
mockResolveEC2Credential.mockResolvedValue({
242247
credentialId: "cred-id",
243248
access: TEST_ACCESS,
@@ -280,12 +285,23 @@ describe("cephProcedure", () => {
280285
"Ceph service not found in catalog"
281286
)
282287
})
288+
289+
it("throws when CEPH_REGION environment variable is not set", async () => {
290+
delete process.env.CEPH_REGION
291+
const ctx = createMockContext()
292+
const caller = createCaller(ctx)
293+
294+
await expect(caller.test.checkStatus({ project_id: TEST_PROJECT_ID })).rejects.toThrow(
295+
"Ceph service not found in catalog"
296+
)
297+
})
283298
})
284299
})
285300

286301
describe("cephCredentialMiddleware", () => {
287302
beforeEach(() => {
288303
vi.clearAllMocks()
304+
process.env.CEPH_REGION = "ceph-objectstore-ec-st1-qa-de-1"
289305
mockCreateS3Client.mockReturnValue({ send: vi.fn() } as MockS3Client as S3Client)
290306
})
291307

@@ -301,6 +317,7 @@ describe("cephProcedure", () => {
301317
})
302318

303319
it("adds cephRegion to context", async () => {
320+
process.env.CEPH_REGION = "ceph-objectstore-st1-eu-de-2"
304321
mockResolveEC2Credential.mockResolvedValue({ credentialId: "cred-id", access: TEST_ACCESS, secret: TEST_SECRET })
305322
const ctx = createMockContext({ region: "eu-de-2" })
306323
const caller = createCaller(ctx)
@@ -348,6 +365,7 @@ describe("cephProcedure", () => {
348365
describe("cephProtectedProcedure", () => {
349366
beforeEach(() => {
350367
vi.clearAllMocks()
368+
process.env.CEPH_REGION = "ceph-objectstore-ec-st1-qa-de-1"
351369
mockCreateS3Client.mockReturnValue({ send: vi.fn() } as MockS3Client as S3Client)
352370
})
353371

0 commit comments

Comments
 (0)