Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add aws tests #207

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"start:test": "dotenv -e test/.env.test yarn dev",
"test": "PORT=3003 start-server-and-test 'yarn start:test' 3003 'dotenv -e test/.env.test jest --runInBand'",
"test:unit": "dotenv -e test/.env.test jest test/unit/",
"test:integration": "dotenv -e test/.env.test jest test/integration/",
"test:e2e": "PORT=3003 start-server-and-test 'yarn start:test' 3003 'dotenv -e test/.env.test jest --runInBand --collectCoverage=false test/e2e/'"
},
"eslintConfig": {
Expand All @@ -38,7 +39,7 @@
"web3.storage": "^4.2.0"
},
"devDependencies": {
"@snapshot-labs/eslint-config": "^0.1.0-beta.11",
"@snapshot-labs/eslint-config": "^0.1.0-beta.15",
"@snapshot-labs/prettier-config": "^0.1.0-beta.7",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.3",
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ describe('GET /ipfs/:cid', () => {

describe('when the IPFS cid does not exist', () => {
it('returns a 400 error', async () => {
const response = await request(HOST).get('/ipfs/test');
const response = await request(HOST).get('/ipfs/noexists');

console.log(response.body);
expect(response.statusCode).toBe(400);
}, 30e3);
});
Expand Down
60 changes: 60 additions & 0 deletions test/integration/aws.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { randomUUID } from 'crypto';
import { set, get, remove } from '../../src/aws';

const KEY_PREFIX = `test-${randomUUID()}`;

describe('aws', () => {
describe('set()', () => {
const data = { foo: 'test-set' };

it('should set a value', async () => {
expect(set(`${KEY_PREFIX}-set`, data)).resolves.toBeTruthy();

await new Promise(resolve => {
setTimeout(resolve, 3e3);
});

expect(get(`${KEY_PREFIX}-set`)).resolves.toEqual(data);
});
});

describe('get()', () => {
const data = { foo: 'test-get' };

beforeAll(async () => {
await set(`${KEY_PREFIX}-get`, data);
});

describe('when the key exist', () => {
it('should return the value', async () => {
expect(get(`${KEY_PREFIX}-get`)).resolves.toEqual(data);
});
});

describe('when the key does not exist', () => {
it('should return false', async () => {
expect(get(`${KEY_PREFIX}-get-no-exist`)).resolves.toBe(false);
});
});
});

describe('remove()', () => {
const data = { foo: `${KEY_PREFIX}-remove` };

beforeAll(async () => {
await set(`${KEY_PREFIX}-remove`, data);
});

describe('when the file exist', () => {
it('should remove a value', async () => {
expect(remove(`${KEY_PREFIX}-remove`)).resolves.toBeTruthy();
});
});

describe('when the file does not exist', () => {
it('should return false', async () => {
expect(remove(`${KEY_PREFIX}-remove-no-exist`)).resolves;
});
});
});
});
Loading
Loading