Skip to content

Commit

Permalink
fix: fix test to not fail if cache credentials are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Oct 2, 2023
1 parent ff58914 commit 7bf0405
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions test/e2e/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,36 @@ describe('GET /ipfs/:cid', () => {
});

describe('when the file is cached', () => {
const cachedContent = { status: 'CACHED' };
if (process.env.AWS_REGION) {
const cachedContent = { status: 'CACHED' };

it('returns the cache file', async () => {
await set(cid, cachedContent);
const response = await request(HOST).get(path);
it('returns the cache file', async () => {
await set(cid, cachedContent);
const response = await request(HOST).get(path);

expect(response.body).toEqual(cachedContent);
expect(response.statusCode).toBe(200);
expect(response.headers['content-type']).toBe('application/json; charset=utf-8');
expect(await get(cid)).toEqual(cachedContent);
});
expect(response.body).toEqual(cachedContent);
expect(response.statusCode).toBe(200);
expect(response.headers['content-type']).toBe('application/json; charset=utf-8');
expect(await get(cid)).toEqual(cachedContent);
});
} else {
it.todo('needs to set AWS credentials to test the cache');
}
});

describe('when the file is not cached', () => {
it('returns the file and caches it', async () => {
const response = await request(HOST).get(path);

expect(response.body).toEqual(content);
expect(response.statusCode).toBe(200);
expect(response.headers['content-type']).toBe('application/json; charset=utf-8');
expect(await get(cid)).toEqual(response.body);
});
if (process.env.AWS_REGION) {
it('returns the file and caches it', async () => {
const response = await request(HOST).get(path);

expect(response.body).toEqual(content);
expect(response.statusCode).toBe(200);
expect(response.headers['content-type']).toBe('application/json; charset=utf-8');
expect(await get(cid)).toEqual(response.body);
});
} else {
it.todo('needs to set AWS credentials to test the cache');
}
});

it('returns a 415 error when not a JSON file', async () => {
Expand Down

0 comments on commit 7bf0405

Please sign in to comment.