diff options
author | Andrei Belov <defan@nginx.com> | 2019-05-30 17:44:29 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2019-05-30 17:44:29 +0300 |
commit | 4921df052be8437d912f3c60faa9a667890e4498 (patch) | |
tree | 3678c551f148a0d177721597de978c090237f205 /test/unit/applications/lang/go.py | |
parent | 3b7a7ff2aa5840d4238584410ee1ebc6860fb9c5 (diff) | |
parent | 7da320a93af07765e79c929287704936c431f3cd (diff) | |
download | unit-4921df052be8437d912f3c60faa9a667890e4498.tar.gz unit-4921df052be8437d912f3c60faa9a667890e4498.tar.bz2 |
Merged with the default branch.1.9.0-1
Diffstat (limited to '')
-rw-r--r-- | test/unit/applications/lang/go.py | 40 |
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..e4ab8ffa --- /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._load_conf( + { + "listeners": {"*:7080": {"pass": "applications/" + script}}, + "applications": { + script: { + "type": "external", + "processes": {"spare": 0}, + "working_directory": go_app_path + script, + "executable": self.testdir + '/go/' + name, + } + }, + } + ) |