summaryrefslogtreecommitdiffhomepage
path: root/test/unit/applications/lang/go.py
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2019-03-28 18:43:13 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2019-03-28 18:43:13 +0300
commit19eba1730a1ca839ed62a37f34c204f580d1b653 (patch)
treee9f54ca64fc7db66e33350826c76ef3814cfa4a0 /test/unit/applications/lang/go.py
parent06b9a11494561e309114266bfe3bb001352b596c (diff)
downloadunit-19eba1730a1ca839ed62a37f34c204f580d1b653.tar.gz
unit-19eba1730a1ca839ed62a37f34c204f580d1b653.tar.bz2
Tests: unit module refactoring.
Diffstat (limited to 'test/unit/applications/lang/go.py')
-rw-r--r--test/unit/applications/lang/go.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/unit/applications/lang/go.py b/test/unit/applications/lang/go.py
new file mode 100644
index 00000000..4852459c
--- /dev/null
+++ b/test/unit/applications/lang/go.py
@@ -0,0 +1,40 @@
+import os
+from subprocess import Popen
+from unit.applications.proto import TestApplicationProto
+
+
+class TestApplicationGo(TestApplicationProto):
+ def load(self, script, name='app'):
+
+ if not os.path.isdir(self.testdir + '/go'):
+ os.mkdir(self.testdir + '/go')
+
+ go_app_path = self.current_dir + '/go/'
+
+ env = os.environ.copy()
+ env['GOPATH'] = self.pardir + '/go'
+ process = Popen(
+ [
+ 'go',
+ 'build',
+ '-o',
+ self.testdir + '/go/' + name,
+ go_app_path + script + '/' + name + '.go',
+ ],
+ env=env,
+ )
+ process.communicate()
+
+ self.conf(
+ {
+ "listeners": {"*:7080": {"application": script}},
+ "applications": {
+ script: {
+ "type": "external",
+ "processes": {"spare": 0},
+ "working_directory": go_app_path + script,
+ "executable": self.testdir + '/go/' + name,
+ }
+ },
+ }
+ )