node.py (1635:97afbb6c5a15) node.py (1654:fc7d0578e124)
1import shutil
2from urllib.parse import quote
3
4from conftest import option
5from conftest import public_dir
6from unit.applications.proto import TestApplicationProto
7
8
9class TestApplicationNode(TestApplicationProto):
10 def load(self, script, name='app.js', **kwargs):
11 # copy application
12
13 shutil.copytree(
1import shutil
2from urllib.parse import quote
3
4from conftest import option
5from conftest import public_dir
6from unit.applications.proto import TestApplicationProto
7
8
9class TestApplicationNode(TestApplicationProto):
10 def load(self, script, name='app.js', **kwargs):
11 # copy application
12
13 shutil.copytree(
14 option.test_dir + '/node/' + script, self.temp_dir + '/node'
14 option.test_dir + '/node/' + script, option.temp_dir + '/node'
15 )
16
17 # copy modules
18
19 shutil.copytree(
20 option.current_dir + '/node/node_modules',
15 )
16
17 # copy modules
18
19 shutil.copytree(
20 option.current_dir + '/node/node_modules',
21 self.temp_dir + '/node/node_modules',
21 option.temp_dir + '/node/node_modules',
22 )
23
22 )
23
24 public_dir(self.temp_dir + '/node')
24 public_dir(option.temp_dir + '/node')
25
26 self._load_conf(
27 {
28 "listeners": {
29 "*:7080": {"pass": "applications/" + quote(script, '')}
30 },
31 "applications": {
32 script: {
33 "type": "external",
34 "processes": {"spare": 0},
25
26 self._load_conf(
27 {
28 "listeners": {
29 "*:7080": {"pass": "applications/" + quote(script, '')}
30 },
31 "applications": {
32 script: {
33 "type": "external",
34 "processes": {"spare": 0},
35 "working_directory": self.temp_dir + '/node',
35 "working_directory": option.temp_dir + '/node',
36 "executable": name,
37 }
38 },
39 },
40 **kwargs
41 )
36 "executable": name,
37 }
38 },
39 },
40 **kwargs
41 )