Skip to content

Commit 84febfe

Browse files
committed
basic integration test working
1 parent e34ae0c commit 84febfe

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

__tests__/basic.test.js

+24-21
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11

22
const Minio = require("minio");
3+
const request = require("supertest");
34

4-
const FILES = [
5-
{
6-
path: "/foo/bar.txt",
7-
content: "dog"
5+
const FILES = {
6+
"/foo/bar.txt": {
7+
content: "dog",
88
},
9-
{
10-
path: "/foo/baz.txt",
11-
content: "cat"
9+
"/foo/baz.txt": {
10+
content: "cat",
1211
},
13-
{
14-
path: "/grumpy.txt",
15-
content: "bah"
16-
}
17-
];
12+
"/grumpy.txt": {
13+
content: "bah",
14+
},
15+
};
1816

19-
const BUCKET_NAME = "javier";
17+
const BUCKET_NAME = "bucket-1";
2018

2119
beforeAll(async () => {
2220
const minioClient = new Minio.Client({
@@ -27,25 +25,30 @@ beforeAll(async () => {
2725
secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
2826
});
2927

30-
ensureBucketWithObjects(minioClient, BUCKET_NAME, FILES);
28+
await ensureBucketWithObjects(minioClient, BUCKET_NAME, FILES);
3129
});
3230

3331
async function ensureBucketWithObjects(s3Client, bucketName, objects) {
3432
if (await s3Client.bucketExists(BUCKET_NAME)) {
35-
await s3Client.removeObjects(BUCKET_NAME, FILES.map((f) => f.path));
33+
await s3Client.removeObjects(BUCKET_NAME, Object.keys(FILES));
3634
await s3Client.removeBucket(BUCKET_NAME);
3735
}
3836

3937
await s3Client.makeBucket(BUCKET_NAME, 'us-east-1');
4038

41-
for (const i in FILES) {
42-
console.log(`now loading file ${FILES[i]}`)
43-
let buf = Buffer.from(FILES[i].content, "utf-8");
44-
let res = await s3Client.putObject(BUCKET_NAME, FILES[i].path, buf);
39+
for (const path of Object.keys(FILES)) {
40+
console.log(`now loading file ${path}`);
41+
let buf = Buffer.from(FILES[path].content, "utf-8");
42+
let res = await s3Client.putObject(BUCKET_NAME, path, buf);
4543
console.log(`Uploaded file: ${JSON.stringify(res)}`);
4644
}
4745
}
4846

49-
test('adds 1 + 2 to equal 3', () => {
50-
expect(true).toBe(true);
47+
test('adds 1 + 2 to equal 3', async () => {
48+
const res = await request('http://localhost:8989')
49+
.get("/foo/bar.txt")
50+
.set("accept", "binary/octet-stream");
51+
52+
expect(res.statusCode).toBe(200);
53+
expect(res.text).toBe(FILES["/foo/bar.txt"].content);
5154
});

common/etc/nginx/templates/default.conf.template

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ map $request_uri $uri_full_path {
1515

1616
# Remove/replace a portion of request URL (if configured)
1717
map $uri_full_path $uri_path {
18-
"~^$STRIP_LEADING_DIRECTORY_PATH(.*)" ${PREFIX_LEADING_DIRECTORY_PATH}$1;
19-
default ${PREFIX_LEADING_DIRECTORY_PATH}$uri_full_path;
18+
"~^$STRIP_LEADING_DIRECTORY_PATH(.*)" $PREFIX_LEADING_DIRECTORY_PATH$1;
19+
default $PREFIX_LEADING_DIRECTORY_PATH$uri_full_path;
2020
}
2121

2222
map $S3_STYLE $s3_host_hdr {

test/docker-compose.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ services:
2929
ALLOW_DIRECTORY_LIST: "false"
3030
PROVIDE_INDEX_PAGE:
3131
APPEND_SLASH_FOR_POSSIBLE_DIRECTORY:
32-
STRIP_LEADING_DIRECTORY_PATH:
33-
PREFIX_LEADING_DIRECTORY_PATH:
32+
STRIP_LEADING_DIRECTORY_PATH: ""
33+
PREFIX_LEADING_DIRECTORY_PATH: ""
3434
AWS_SIGS_VERSION: "4"
3535
STATIC_SITE_HOSTING:
3636
PROXY_CACHE_MAX_SIZE: "10g"

0 commit comments

Comments
 (0)