Skip to content

Commit

Permalink
Merge pull request #127 from voyagegroup/nginx_test_infrataster
Browse files Browse the repository at this point in the history
Nginx test infrataster
  • Loading branch information
jewelpet authored Nov 8, 2016
2 parents b2055d1 + 032e184 commit e6bb3ad
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sudo: false
sudo: required

services:
- docker

language: node_js

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ cp_js: clean_obj
####################################
test: ## Run all unit tests and lints.
$(NPM_BIN)/cross-env NODE_ENV=development make run_test -j 16 -C ./
make -C docker test

run_test: build lint build_test
$(NPM_BIN)/cross-env TEST_TARGET=$(TEST_TARGET) $(NODE_BIN) ./tools/test_launcher.js
Expand Down
4 changes: 4 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ devcontainer: ./DEV.Dockerfile ## Create the Docker container for development in

run_devcontainer: devcontainer ## Start up the docker container build by `make devcontainer`.
docker run -p $(DEV_CONTAINER_HOST_PORT):80 -v $(PROJECT_ROOT)/__dist:/usr/share/nginx/html:ro $(DEV_CONTAINER_NAME)

test:
docker-compose up --build --abort-on-container-exit
! docker-compose ps | grep 'Exit 1'
17 changes: 17 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "2"
services:
web:
build:
context: ./
dockerfile: ./DEV.Dockerfile
ports:
- 80
volumes:
- ../__dist:/usr/share/nginx/html:ro
test:
image: quay.io/spesnova/infrataster
volumes:
- ./spec:/test/spec
depends_on:
- web
network_mode: "service:web"
15 changes: 15 additions & 0 deletions docker/spec/css_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'spec_helper'

describe server(:web) do
describe http('http://web/css/bundle.css') do
it "returns 200" do
expect(response.status).to eq(200)
end
it "returns test/css" do
expect(response.headers['Content-Type']).to eq("text/css")
end
it "responds content contains charset declaration" do
expect(response.body).to include("@charset 'utf-8';")
end
end
end
27 changes: 27 additions & 0 deletions docker/spec/operator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'spec_helper'

describe server(:web) do
describe http('http://web/operator/') do
it "returns 200" do
expect(response.status).to eq(200)
end
it "returns test/html" do
expect(response.headers['Content-Type']).to eq("text/html")
end
it "responds content loads operator.js" do
expect(response.body).to include('<script defer src="/js/operator.js"></script>')
end
end

describe http('http://web/js/operator.js') do
it "returns 200" do
expect(response.status).to eq(200)
end
it "returns test/css" do
expect(response.headers['Content-Type']).to eq("application/javascript")
end
it "responds content contains 'use strict'" do
expect(response.body).to include("'use strict';")
end
end
end
27 changes: 27 additions & 0 deletions docker/spec/public_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'spec_helper'

describe server(:web) do
describe http('http://web/') do
it "returns 200" do
expect(response.status).to eq(200)
end
it "returns test/html" do
expect(response.headers['Content-Type']).to eq("text/html")
end
it "responds content loads public.js" do
expect(response.body).to include('<script defer src="/js/public.js"></script>')
end
end

describe http('http://web/js/public.js') do
it "returns 200" do
expect(response.status).to eq(200)
end
it "returns test/css" do
expect(response.headers['Content-Type']).to eq("application/javascript")
end
it "responds content contains 'use strict'" do
expect(response.body).to include("'use strict';")
end
end
end
5 changes: 5 additions & 0 deletions docker/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'infrataster/rspec'

Infrataster::Server.define(:web) do |server|
server.address = '127.0.0.1'
end
27 changes: 27 additions & 0 deletions docker/spec/sponsor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'spec_helper'

describe server(:web) do
describe http('http://web/sponsor/') do
it "returns 200" do
expect(response.status).to eq(200)
end
it "returns test/html" do
expect(response.headers['Content-Type']).to eq("text/html")
end
it "responds content loads operator.js" do
expect(response.body).to include('<script defer src="/js/sponsor.js"></script>')
end
end

describe http('http://web/js/sponsor.js') do
it "returns 200" do
expect(response.status).to eq(200)
end
it "returns test/css" do
expect(response.headers['Content-Type']).to eq("application/javascript")
end
it "responds content contains 'use strict'" do
expect(response.body).to include("'use strict';")
end
end
end

0 comments on commit e6bb3ad

Please sign in to comment.