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

nginx-tests: eliminate duplicate dockerfile #741

Merged
merged 3 commits into from
Oct 7, 2024
Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/test-nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- uses: actions/setup-node@v4
with:
node-version: 20.17.0
Expand Down
28 changes: 0 additions & 28 deletions test/nginx-test.dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion test/nginx.test.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
nginx:
build:
context: ..
dockerfile: ./test/nginx-test.dockerfile
dockerfile: nginx.dockerfile
depends_on:
- service
- enketo
Expand Down
5 changes: 0 additions & 5 deletions test/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ wait_for_http_response() {
fi
}

log "Checking nginx dockerfiles have same base image..."
# It would be nice if Dockerfiles allowed some kind of templating which would
# allow for direct sharing between the real and test nginx dockerfiles.
diff <(grep FROM nginx-test.dockerfile) <(grep FROM ../nginx.dockerfile | grep -v AS)

log "Starting test services..."
docker_compose up --build --detach

Expand Down
13 changes: 7 additions & 6 deletions test/test-nginx.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,31 @@ describe('nginx config', () => {
});

[
'/index.html',
'/version.txt',
].forEach(staticFile => {
[ '/index.html', /<div id="app"><\/div>/ ],
[ '/version.txt', /^versions:/ ],
].forEach(([ staticFile, expectedContent ]) => {
it(`${staticFile} file should have no-cache header`, async () => {
// when
const res = await fetchHttps(staticFile);

// then
assert.equal(res.status, 200);
assert.equal(await res.text(), `hi:${staticFile}\n`);
assert.match(await res.text(), expectedContent);
assert.equal(await res.headers.get('cache-control'), 'no-cache');
});
});

[
'/should-be-cached.txt',
'/blank.html',
'/favicon.ico',
// there's no way to predict generated asset paths, as they have cache-busting names
].forEach(staticFile => {
it(`${staticFile} file should not have no-cache header`, async () => {
// when
const res = await fetchHttps(staticFile);

// then
assert.equal(res.status, 200);
assert.equal(await res.text(), `hi:${staticFile}\n`);
assert.isNull(await res.headers.get('cache-control'));
});
});
Expand Down