xref: /unit/test/unit/applications/lang/node.py (revision 1163:ec7aad540d72)
1import os
2import shutil
3from unit.applications.proto import TestApplicationProto
4
5
6class TestApplicationNode(TestApplicationProto):
7    def load(self, script, name='app.js'):
8        # copy application
9
10        shutil.copytree(
11            self.current_dir + '/node/' + script, self.testdir + '/node'
12        )
13
14        # link modules
15
16        os.symlink(
17            self.pardir + '/node/node_modules',
18            self.testdir + '/node/node_modules',
19        )
20
21        self._load_conf(
22            {
23                "listeners": {"*:7080": {"pass": "applications/" + script}},
24                "applications": {
25                    script: {
26                        "type": "external",
27                        "processes": {"spare": 0},
28                        "working_directory": self.testdir + '/node',
29                        "executable": name,
30                    }
31                },
32            }
33        )
34