Permalink
Browse files

feat: integration test

  • Loading branch information...
moul committed Dec 20, 2018
1 parent 7661ca0 commit aa9c33495ce45120815be06fedfc8366a78e3a96
Showing with 83 additions and 17 deletions.
  1. +24 −17 .circleci/config.yml
  2. +16 −0 Makefile
  3. +11 −0 docker-compose.yml
  4. +8 −0 test/Dockerfile
  5. +15 −0 test/docker-compose.yml
  6. +9 −0 test/integration.sh
@@ -12,9 +12,7 @@ jobs:
steps:
- checkout
- setup_remote_docker
- run:
name: docker build
command: docker build -t pathwar/pathwar .
- run: docker build -t pathwar/pathwar .
# FIXME: save cache

# build and unit test the project
@@ -28,26 +26,35 @@ jobs:
steps:
- checkout
# FIXME: restore cache
- run:
name: fetch dependencies
command: |
go clean -modcache
go get
- run:
name: install
command: |
sleep 1
touch .generated
make install
- run:
name: test
command: make test
- run: go clean -modcache
- run: go get
- run: make _ci_prepare
- run: make test
# FIXME: save cache
# FIXME: store_test_results

docker.integration:
docker:
- image: docker:17.05.0-ce-git
steps:
- checkout
- run:
name: Install Deps
command: |
apk --no-cache add curl openssl python3 make bash
pip3 install -U pip docker-compose
docker-compose --version
- setup_remote_docker:
docker_layer_caching: true
- run: docker build -t pathwar/pathwar .
- run: make docker.integration
- run: make docker.integration
- run: docker-compose logs

workflows:
version: 2
commit:
jobs:
- test
- docker.build
- docker.integration
@@ -45,6 +45,12 @@ $(BIN): .generated $(OUR_SOURCES)
clean:
rm -f $(GENERATED_FILES) .generated

.PHONY: _ci_prepare
_ci_prepare:
touch $(OUR_PROTOS) $(GENERATED_FILES)
sleep 1
touch .generated

.PHONY: generate
generate: .generated
.generated: $(OUR_PROTOS)
@@ -77,3 +83,13 @@ test: .generated
.PHONY: docker.build
docker.build:
docker build -t pathwar/pathwar .

.PHONY: docker.integration
docker.integration:
docker-compose -f ./test/docker-compose.yml up -d server
docker-compose -f ./test/docker-compose.yml run client
docker-compose -f ./test/docker-compose.yml down

.PHONY: integration
integration:
./test/integration.sh
@@ -0,0 +1,11 @@
version: '2.3'

services:
server:
&server
image: pathwar/pathwar
command: server
#depends_on:
# - mysql
ports:
- 8000
@@ -0,0 +1,8 @@
FROM alpine
RUN apk --no-cache add curl openssl python3 make bash jq \
&& pip3 install -U pip setuptools httpie \
&& http --version \
&& jq --version
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["sleep 5; ./integration.sh"]
COPY . .
@@ -0,0 +1,15 @@
version: '2.3'

services:
server:
extends:
file: ../docker-compose.yml
service: server

client:
build: .
environment:
TARGET: http://server:8000
depends_on:
- server
tty: true
@@ -0,0 +1,9 @@
#!/bin/bash -xe
# depends on: httpie, jq

TARGET="${TARGET:-http://localhost:8000}"

http --check-status "${TARGET}"/ping
token=$(http --check-status "${TARGET}"/authenticate username=integration | jq -r .token)
test "$(http --check-status "${TARGET}"/session | jq -r .message)" = "no token provided"
test "$(http --check-status "${TARGET}"/session "Authorization:$token" | jq -r .username)" = "integration"

0 comments on commit aa9c334

Please sign in to comment.