]> git.immae.eu Git - github/fretlink/ansible-kong-app.git/commitdiff
tests: fake a Kong server 18/head
authorPaul Bonaud <paul.bonaud@fretlink.com>
Thu, 2 Jan 2020 14:25:06 +0000 (15:25 +0100)
committerPaul Bonaud <paul.bonaud@fretlink.com>
Thu, 2 Jan 2020 14:50:17 +0000 (15:50 +0100)
.travis.yml
tests/kong.py [new file with mode: 0755]

index 1deea24b5532eadc9bb4211b2fddbdb9ed7de596..14ab868b529eae5894a46235d4d8934a6757c3b3 100644 (file)
@@ -13,7 +13,7 @@ install:
   - nix-channel --update
 
   # Install ansible
-  - nix-env -i ansible ansible-lint
+  - nix-env -i python3 ansible ansible-lint
   - nix-env -if ./dhall-1.26.1.nix
 
   # Check ansible version
@@ -22,12 +22,15 @@ install:
 
   # Create ansible.cfg with correct roles_path
   - printf '[defaults]\nroles_path=../' >ansible.cfg
+  # Basic webserver to fake a Kong
+  - |
+    ./tests/kong.py&
 
 script:
   # Basic role syntax check
   - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
   - ansible-lint .
-  - ansible-playbook tests/test.yml -i tests/inventory -C -D
+  - ansible-playbook tests/test.yml -i tests/inventory -D
   - scripts/dhall_check.sh
 
 notifications:
diff --git a/tests/kong.py b/tests/kong.py
new file mode 100755 (executable)
index 0000000..32bafb2
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+from http.server import HTTPServer, CGIHTTPRequestHandler
+
+class SimpleHTTPRequestHandler(CGIHTTPRequestHandler):
+    def do_GET(self):
+        if self.path == '/services/test':
+            self.send_response(404)
+        else:
+            self.send_response(200)
+        self.send_header('Content-Type', 'application/json')
+        self.end_headers()
+        self.wfile.write(b'{ "data": [] }')
+
+    def do_POST(self):
+        self.send_response(200)
+        self.end_headers()
+        self.wfile.write(b'Hello, world!')
+
+
+httpd = HTTPServer(('127.0.0.1', 8000), SimpleHTTPRequestHandler)
+httpd.serve_forever()