Merge pull request #5608 from dokku/convert-config-test
tests: refactor the config test to use a simple python codebase instead
This commit is contained in:
7 files changed
+46
-28
No files matched your search
Whitespace-only changes.
@@ -1 +1 @@
|
|||||||
web: node web.js
|
web: python3 -u web.py
|
||||||
@@ -11,6 +11,7 @@ test_url() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
base_url="$1"
|
base_url="$1"
|
||||||
test_url / "config-test"
|
test_url / "python/http.server"
|
||||||
|
test_url /conftest "config-test"
|
||||||
test_url /hello "Hello
|
test_url /hello "Hello
|
||||||
'world'"
|
'world'"
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "node-example",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"dependencies": {
|
|
||||||
"express": "4.18.x"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "4.2.x"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
var express = require('express');
|
|
||||||
|
|
||||||
var app = express();
|
|
||||||
|
|
||||||
app.get('/', function(request, response) {
|
|
||||||
response.send(process.env.CONFTEST);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/hello', function(request, response) {
|
|
||||||
response.send(process.env.HELLO);
|
|
||||||
});
|
|
||||||
|
|
||||||
var port = process.env.PORT || 5000;
|
|
||||||
app.listen(port, function() {
|
|
||||||
console.log("Listening on " + port);
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import http.server
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
class GetHandler(http.server.BaseHTTPRequestHandler):
|
||||||
|
def do_GET(self):
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header("Content-Type", "text/plain; charset=utf-8")
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
if self.path == '/':
|
||||||
|
self.wfile.write("python/http.server".encode("utf-8"))
|
||||||
|
elif self.path == '/conftest':
|
||||||
|
value = os.getenv("CONFTEST", "")
|
||||||
|
self.wfile.write(value.encode("utf-8"))
|
||||||
|
elif self.path == '/hello':
|
||||||
|
value = os.getenv("HELLO", "")
|
||||||
|
self.wfile.write(value.encode("utf-8"))
|
||||||
|
else:
|
||||||
|
data = json.dumps(dict(os.environ), sort_keys=True, indent=4)
|
||||||
|
self.wfile.write(data.encode("utf-8"))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if os.getenv("FAIL_ON_STARTUP") == "true":
|
||||||
|
print("Failing on startup due to FAIL_ON_STARTUP=true")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for arg in sys.argv:
|
||||||
|
print(f"Arg: {arg}")
|
||||||
|
|
||||||
|
port = int(os.getenv("PORT", 5000))
|
||||||
|
server = http.server.HTTPServer(("0.0.0.0", port), GetHandler)
|
||||||
|
print("Listening on port {0}".format(port))
|
||||||
|
server.serve_forever()
|
||||||
@@ -12,6 +12,12 @@ class GetHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
if self.path == '/':
|
if self.path == '/':
|
||||||
self.wfile.write("python/http.server".encode("utf-8"))
|
self.wfile.write("python/http.server".encode("utf-8"))
|
||||||
|
elif self.path == '/conftest':
|
||||||
|
value = os.getenv("CONFTEST", "")
|
||||||
|
self.wfile.write(value.encode("utf-8"))
|
||||||
|
elif self.path == '/hello':
|
||||||
|
value = os.getenv("HELLO", "")
|
||||||
|
self.wfile.write(value.encode("utf-8"))
|
||||||
else:
|
else:
|
||||||
data = json.dumps(dict(os.environ), sort_keys=True, indent=4)
|
data = json.dumps(dict(os.environ), sort_keys=True, indent=4)
|
||||||
self.wfile.write(data.encode("utf-8"))
|
self.wfile.write(data.encode("utf-8"))
|
||||||
|
|||||||
Reference in new issue
Block a user