Merge pull request #1996 from balena-os/test-in-docker

Refactor test suite to use tsconfig paths instead of relative paths
This commit is contained in:
bulldozer-balena[bot] 2022-08-22 21:00:05 +00:00 committed by GitHub
commit b092fa9cb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 533 additions and 502 deletions

View File

@ -96,13 +96,13 @@ COPY --from=build-base /usr/src/app/node_modules ./node_modules
# Copy build files # Copy build files
COPY build-utils ./build-utils COPY build-utils ./build-utils
COPY webpack.config.js tsconfig.json tsconfig.release.json ./ COPY webpack.config.js tsconfig.json tsconfig.release.json tsconfig.js.json ./
COPY src ./src COPY src ./src
COPY test ./test COPY test ./test
COPY typings ./typings COPY typings ./typings
# Run the tests # Run the tests
RUN npm run test-nolint RUN npm run test
################################################### ###################################################
# Build the production package # Build the production package

View File

@ -176,7 +176,7 @@ balena build -d raspberrypi4-64 -A aarch64
## Testing ## Testing
You can run some unit tests with: You can run the supervisor test suite with:
``` ```
npm test npm test
@ -191,14 +191,14 @@ which ensures that the environment is exactly the same.
#### Running specific tests quickly #### Running specific tests quickly
You can run specific tests quickly with the `test:fast` script by matching with test suites (describe) or test cases (it) using a string or regexp: You can run specific tests quickly with the `test:node` script by matching with test suites (describe) or test cases (it) using a string or regexp:
```sh ```sh
npm run test:fast -- -g spawnJournalctl npm run test:node -- -g spawnJournalctl
npm run test:fast -- -g "detect a V2 delta" npm run test:node -- -g "detect a V2 delta"
npm run test:fast -- -g (GET|POST|PUT|DELETE) npm run test:node -- -g (GET|POST|PUT|DELETE)
``` ```
The --grep option, when specified, will trigger mocha to only run tests matching the given pattern which is internally compiled to a RegExp. The --grep option, when specified, will trigger mocha to only run tests matching the given pattern which is internally compiled to a RegExp.

92
package-lock.json generated
View File

@ -378,14 +378,16 @@
"version": "1.8.3", "version": "1.8.3",
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz",
"integrity": "sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==", "integrity": "sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==",
"dev": true,
"requires": { "requires": {
"type-detect": "4.0.8" "type-detect": "4.0.8"
} }
}, },
"@sinonjs/fake-timers": { "@sinonjs/fake-timers": {
"version": "7.0.5", "version": "7.1.2",
"resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.0.5.tgz", "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz",
"integrity": "sha512-fUt6b15bjV/VW93UP5opNXJxdwZSbK1EdiwnhN7XrQrcpaOhMJpZ/CjwFpM3THpxwA+YviBUJKSuEqKlCK5alw==", "integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==",
"dev": true,
"requires": { "requires": {
"@sinonjs/commons": "^1.7.0" "@sinonjs/commons": "^1.7.0"
} }
@ -394,6 +396,7 @@
"version": "6.1.1", "version": "6.1.1",
"resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-6.1.1.tgz", "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-6.1.1.tgz",
"integrity": "sha512-cZ7rKJTLiE7u7Wi/v9Hc2fs3Ucc3jrWeMgPHbbTCeVAB2S0wOBbYlkJVeNSL04i7fdhT8wIbDq1zhC/PXTD2SA==", "integrity": "sha512-cZ7rKJTLiE7u7Wi/v9Hc2fs3Ucc3jrWeMgPHbbTCeVAB2S0wOBbYlkJVeNSL04i7fdhT8wIbDq1zhC/PXTD2SA==",
"dev": true,
"requires": { "requires": {
"@sinonjs/commons": "^1.6.0", "@sinonjs/commons": "^1.6.0",
"lodash.get": "^4.4.2", "lodash.get": "^4.4.2",
@ -401,9 +404,10 @@
} }
}, },
"@sinonjs/text-encoding": { "@sinonjs/text-encoding": {
"version": "0.7.1", "version": "0.7.2",
"resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz",
"integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==" "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==",
"dev": true
}, },
"@szmarczak/http-timer": { "@szmarczak/http-timer": {
"version": "1.1.2", "version": "1.1.2",
@ -1723,7 +1727,8 @@
"dependencies": { "dependencies": {
"ansi-regex": { "ansi-regex": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true "dev": true
}, },
"ansi-styles": { "ansi-styles": {
@ -2434,7 +2439,8 @@
"dependencies": { "dependencies": {
"ansi-regex": { "ansi-regex": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true "dev": true
}, },
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
@ -3306,7 +3312,8 @@
"diff": { "diff": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz",
"integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==" "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==",
"dev": true
}, },
"diffie-hellman": { "diffie-hellman": {
"version": "5.0.3", "version": "5.0.3",
@ -6216,7 +6223,8 @@
"just-extend": { "just-extend": {
"version": "4.2.1", "version": "4.2.1",
"resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz",
"integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==" "integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==",
"dev": true
}, },
"keyv": { "keyv": {
"version": "3.1.0", "version": "3.1.0",
@ -6610,7 +6618,8 @@
"lodash.get": { "lodash.get": {
"version": "4.4.2", "version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==",
"dev": true
}, },
"lodash.set": { "lodash.set": {
"version": "4.3.2", "version": "4.3.2",
@ -7180,7 +7189,8 @@
"dependencies": { "dependencies": {
"ansi-regex": { "ansi-regex": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true "dev": true
}, },
"ansi-styles": { "ansi-styles": {
@ -7603,6 +7613,7 @@
"version": "5.1.1", "version": "5.1.1",
"resolved": "https://registry.npmjs.org/nise/-/nise-5.1.1.tgz", "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.1.tgz",
"integrity": "sha512-yr5kW2THW1AkxVmCnKEh4nbYkJdB3I7LUkiUgOvEkOp414mc2UMaHMA7pjq1nYowhdoJZGwEKGaQVbxfpWj10A==", "integrity": "sha512-yr5kW2THW1AkxVmCnKEh4nbYkJdB3I7LUkiUgOvEkOp414mc2UMaHMA7pjq1nYowhdoJZGwEKGaQVbxfpWj10A==",
"dev": true,
"requires": { "requires": {
"@sinonjs/commons": "^1.8.3", "@sinonjs/commons": "^1.8.3",
"@sinonjs/fake-timers": ">=5", "@sinonjs/fake-timers": ">=5",
@ -7614,12 +7625,14 @@
"isarray": { "isarray": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==",
"dev": true
}, },
"path-to-regexp": { "path-to-regexp": {
"version": "1.8.0", "version": "1.8.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz",
"integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==",
"dev": true,
"requires": { "requires": {
"isarray": "0.0.1" "isarray": "0.0.1"
} }
@ -9286,6 +9299,7 @@
"version": "11.1.2", "version": "11.1.2",
"resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz", "resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz",
"integrity": "sha512-59237HChms4kg7/sXhiRcUzdSkKuydDeTiamT/jesUVHshBgL8XAmhgFo0GfK6RruMDM/iRSij1EybmMog9cJw==", "integrity": "sha512-59237HChms4kg7/sXhiRcUzdSkKuydDeTiamT/jesUVHshBgL8XAmhgFo0GfK6RruMDM/iRSij1EybmMog9cJw==",
"dev": true,
"requires": { "requires": {
"@sinonjs/commons": "^1.8.3", "@sinonjs/commons": "^1.8.3",
"@sinonjs/fake-timers": "^7.1.2", "@sinonjs/fake-timers": "^7.1.2",
@ -9295,23 +9309,17 @@
"supports-color": "^7.2.0" "supports-color": "^7.2.0"
}, },
"dependencies": { "dependencies": {
"@sinonjs/fake-timers": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz",
"integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==",
"requires": {
"@sinonjs/commons": "^1.7.0"
}
},
"has-flag": { "has-flag": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
}, },
"supports-color": { "supports-color": {
"version": "7.2.0", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": { "requires": {
"has-flag": "^4.0.0" "has-flag": "^4.0.0"
} }
@ -9752,6 +9760,12 @@
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
}, },
"strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
"integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==",
"dev": true
},
"strip-final-newline": { "strip-final-newline": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz",
@ -10438,6 +10452,31 @@
} }
} }
}, },
"tsconfig-paths": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.1.0.tgz",
"integrity": "sha512-AHx4Euop/dXFC+Vx589alFba8QItjF+8hf8LtmuiCwHyI4rHXQtOOENaM8kvYf5fR0dRChy3wzWIZ9WbB7FWow==",
"dev": true,
"requires": {
"json5": "^2.2.1",
"minimist": "^1.2.6",
"strip-bom": "^3.0.0"
},
"dependencies": {
"json5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
"dev": true
},
"minimist": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
"dev": true
}
}
},
"tslib": { "tslib": {
"version": "1.9.3", "version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
@ -10572,7 +10611,8 @@
"type-detect": { "type-detect": {
"version": "4.0.8", "version": "4.0.8",
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
"dev": true
}, },
"type-fest": { "type-fest": {
"version": "0.11.0", "version": "0.11.0",
@ -11616,7 +11656,8 @@
"dependencies": { "dependencies": {
"ansi-regex": { "ansi-regex": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true "dev": true
}, },
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
@ -11880,7 +11921,8 @@
"dependencies": { "dependencies": {
"ansi-regex": { "ansi-regex": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true "dev": true
}, },
"cliui": { "cliui": {

View File

@ -1,143 +1,138 @@
{ {
"name": "balena-supervisor", "name": "balena-supervisor",
"description": "This is balena's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as the balena API informs it to.", "description": "This is balena's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as the balena API informs it to.",
"version": "14.0.13", "version": "14.0.13",
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/balena-os/balena-supervisor.git" "url": "https://github.com/balena-os/balena-supervisor.git"
}, },
"scripts": { "scripts": {
"start": "./entry.sh", "start": "./entry.sh",
"build": "npm run release && webpack", "build": "npm run clean && npm run release && webpack",
"build:debug": "npm run release && npm run packagejson:copy", "lint": "balena-lint -e ts -e js --typescript src/ test/ typings/ build-utils/ webpack.config.js",
"lint": "balena-lint -e ts -e js --typescript src/ test/ typings/ build-utils/ webpack.config.js && tsc --noEmit && tsc --noEmit --project tsconfig.js.json", "test:build": "tsc --noEmit && tsc --noEmit --project tsconfig.js.json",
"test": "npm run clean && npm run test-nolint", "test:node": "mocha --config test/.mocharc.js",
"posttest": "npm run lint", "test": "npm run lint && npm run test:build && npm run test:node",
"test-nolint": "npm run test:build && TEST=1 mocha --config test/.mocharc.js", "test:fast": "npm run test:build && npm run test:node",
"test:build": "npm run test-build && npm run testitems:copy && npm run packagejson:copy", "prettify": "balena-lint -e ts -e js --typescript --fix src/ test/ typings/ build-utils/ webpack.config.js",
"test:fast": "TEST=1 mocha --config test/.mocharc.fast.js", "release": "tsc --project tsconfig.release.json && mv build/src/* build",
"test:debug": "npm run test:build && TEST=1 mocha --inspect-brk --config test/.mocharc.js", "sync": "ts-node --files sync/sync.ts",
"prettify": "balena-lint -e ts -e js --typescript --fix src/ test/ typings/ build-utils/ webpack.config.js", "clean": "rimraf build"
"test-build": "tsc --project tsconfig.json", },
"release": "tsc --project tsconfig.release.json && mv build/src/* build", "private": true,
"packagejson:copy": "cp package.json build/", "dependencies": {
"testitems:copy": "cp -r test/data build/test/", "@balena/happy-eyeballs": "0.0.6",
"sync": "ts-node --files sync/sync.ts", "dbus": "^1.0.7",
"clean": "rimraf build" "mdns-resolver": "^1.0.0",
}, "semver": "^7.3.2",
"private": true, "sqlite3": "^4.1.1",
"dependencies": { "systeminformation": "^5.6.10"
"@balena/happy-eyeballs": "0.0.6", },
"dbus": "^1.0.7", "engines": {
"mdns-resolver": "^1.0.0", "node": "^12.16.2",
"semver": "^7.3.2", "npm": "^6.14.4"
"sinon": "^11.1.2", },
"sqlite3": "^4.1.1", "devDependencies": {
"systeminformation": "^5.6.10" "@balena/contrato": "^0.6.0",
}, "@balena/lint": "^5.1.0",
"engines": { "@types/bluebird": "^3.5.32",
"node": "^12.16.2", "@types/chai": "^4.2.16",
"npm": "^6.14.4" "@types/chai-as-promised": "^7.1.3",
}, "@types/chai-like": "^1.1.0",
"devDependencies": { "@types/chai-things": "0.0.34",
"@balena/contrato": "^0.6.0", "@types/common-tags": "^1.8.0",
"@balena/lint": "^5.1.0", "@types/copy-webpack-plugin": "^6.0.0",
"@types/bluebird": "^3.5.32", "@types/dbus": "^1.0.0",
"@types/chai": "^4.2.16", "@types/dockerode": "^2.5.34",
"@types/chai-as-promised": "^7.1.3", "@types/event-stream": "^3.3.34",
"@types/chai-like": "^1.1.0", "@types/express": "^4.17.3",
"@types/chai-things": "0.0.34", "@types/lodash": "^4.14.159",
"@types/common-tags": "^1.8.0", "@types/memoizee": "^0.4.4",
"@types/copy-webpack-plugin": "^6.0.0", "@types/mocha": "^8.2.2",
"@types/dbus": "^1.0.0", "@types/mock-fs": "^4.13.0",
"@types/dockerode": "^2.5.34", "@types/morgan": "^1.9.0",
"@types/event-stream": "^3.3.34", "@types/node": "^12.12.54",
"@types/express": "^4.17.3", "@types/request": "^2.48.5",
"@types/lodash": "^4.14.159", "@types/rewire": "^2.5.28",
"@types/memoizee": "^0.4.4", "@types/rimraf": "^2.0.4",
"@types/mocha": "^8.2.2", "@types/rwlock": "^5.0.2",
"@types/mock-fs": "^4.13.0", "@types/semver": "^7.3.3",
"@types/morgan": "^1.9.0", "@types/shell-quote": "^1.7.0",
"@types/node": "^12.12.54", "@types/sinon": "^10.0.11",
"@types/request": "^2.48.5", "@types/sinon-chai": "^3.2.5",
"@types/rewire": "^2.5.28", "@types/supertest": "^2.0.11",
"@types/rimraf": "^2.0.4", "@types/terser-webpack-plugin": "^3.0.0",
"@types/rwlock": "^5.0.2", "@types/tmp": "^0.1.0",
"@types/semver": "^7.3.3", "@types/webpack": "^4.41.21",
"@types/shell-quote": "^1.7.0", "@types/yargs": "^15.0.12",
"@types/sinon": "^10.0.11", "balena-register-device": "^7.2.0",
"@types/sinon-chai": "^3.2.5", "blinking": "^0.0.4",
"@types/supertest": "^2.0.11", "bluebird": "^3.7.2",
"@types/terser-webpack-plugin": "^3.0.0", "chai": "^4.3.4",
"@types/tmp": "^0.1.0", "chai-as-promised": "^7.1.1",
"@types/webpack": "^4.41.21", "chai-like": "^1.1.1",
"@types/yargs": "^15.0.12", "chai-things": "^0.2.0",
"balena-register-device": "^7.2.0", "chokidar": "^3.5.1",
"blinking": "^0.0.4", "common-tags": "^1.8.0",
"bluebird": "^3.7.2", "copy-webpack-plugin": "^6.0.3",
"chai": "^4.3.4", "deep-object-diff": "^1.1.0",
"chai-as-promised": "^7.1.1", "docker-delta": "^2.2.11",
"chai-like": "^1.1.1", "docker-progress": "^4.0.3",
"chai-things": "^0.2.0", "dockerode": "^2.5.8",
"chokidar": "^3.5.1", "duration-js": "^4.0.0",
"common-tags": "^1.8.0", "event-stream": "3.3.4",
"copy-webpack-plugin": "^6.0.3", "express": "^4.17.1",
"deep-object-diff": "^1.1.0", "fork-ts-checker-webpack-plugin": "^5.1.0",
"docker-delta": "^2.2.11", "fp-ts": "^2.8.1",
"docker-progress": "^4.0.3", "husky": "^4.2.5",
"dockerode": "^2.5.8", "io-ts": "^2.2.10",
"duration-js": "^4.0.0", "io-ts-reporters": "^1.2.2",
"event-stream": "3.3.4", "json-mask": "^0.3.9",
"express": "^4.17.1", "knex": "^0.20.13",
"fork-ts-checker-webpack-plugin": "^5.1.0", "lint-staged": "^10.2.11",
"fp-ts": "^2.8.1", "livepush": "^3.5.1",
"husky": "^4.2.5", "lodash": "^4.17.21",
"io-ts": "^2.2.10", "memoizee": "^0.4.14",
"io-ts-reporters": "^1.2.2", "mixpanel": "^0.10.3",
"json-mask": "^0.3.9", "mocha": "^8.3.2",
"knex": "^0.20.13", "mock-fs": "^4.14.0",
"lint-staged": "^10.2.11", "morgan": "^1.10.0",
"livepush": "^3.5.1", "network-checker": "^0.1.1",
"lodash": "^4.17.21", "nock": "^13.1.2",
"memoizee": "^0.4.14", "nodemon": "^2.0.4",
"mixpanel": "^0.10.3", "pinejs-client-request": "^7.2.1",
"mocha": "^8.3.2", "pretty-ms": "^7.0.1",
"mock-fs": "^4.14.0", "request": "^2.88.2",
"morgan": "^1.10.0", "resin-docker-build": "^1.1.6",
"network-checker": "^0.1.1", "resumable-request": "^2.0.1",
"nock": "^13.1.2", "rewire": "^5.0.0",
"nodemon": "^2.0.4", "rimraf": "^2.7.1",
"pinejs-client-request": "^7.2.1", "rwlock": "^5.0.0",
"pretty-ms": "^7.0.1", "shell-quote": "^1.7.2",
"request": "^2.88.2", "sinon": "^11.1.2",
"resin-docker-build": "^1.1.6", "sinon-chai": "^3.6.0",
"resumable-request": "^2.0.1", "strict-event-emitter-types": "^2.0.0",
"rewire": "^5.0.0", "supertest": "^6.1.3",
"rimraf": "^2.7.1", "tar-stream": "^2.1.3",
"rwlock": "^5.0.0", "terser-webpack-plugin": "^4.1.0",
"shell-quote": "^1.7.2", "tmp": "^0.1.0",
"sinon-chai": "^3.6.0", "ts-loader": "^7.0.5",
"strict-event-emitter-types": "^2.0.0", "ts-node": "^8.10.2",
"supertest": "^6.1.3", "tsconfig-paths": "^4.1.0",
"tar-stream": "^2.1.3", "typed-error": "^3.2.1",
"terser-webpack-plugin": "^4.1.0", "typescript": "^4.2.4",
"tmp": "^0.1.0", "webpack": "^4.44.1",
"ts-loader": "^7.0.5", "webpack-cli": "^3.3.12",
"ts-node": "^8.10.2", "winston": "^3.3.3",
"typed-error": "^3.2.1", "yargs": "^15.4.1"
"typescript": "^4.2.4", },
"webpack": "^4.44.1", "husky": {
"webpack-cli": "^3.3.12", "hooks": {
"winston": "^3.3.3", "pre-commit": "lint-staged"
"yargs": "^15.4.1" }
}, },
"husky": { "versionist": {
"hooks": { "publishedAt": "2022-08-02T21:43:16.303Z"
"pre-commit": "lint-staged" }
}
},
"versionist": {
"publishedAt": "2022-08-02T21:43:16.303Z"
}
} }

View File

@ -1,12 +0,0 @@
module.exports = {
bail: true, // Exit test script on first error
exit: true, // Force Mocha to exit after tests complete
recursive: true, // Look for tests in subdirectories
require: [
// Files to execute before running suites
'ts-node/register/transpile-only',
'test/config/fixtures.ts',
],
spec: ['test/**/*.spec.ts'],
timeout: '30000',
};

View File

@ -4,8 +4,10 @@ module.exports = {
recursive: true, // Look for tests in subdirectories recursive: true, // Look for tests in subdirectories
require: [ require: [
// Files to execute before running suites // Files to execute before running suites
'build/test/config/fixtures.js', 'ts-node/register/transpile-only',
'tsconfig-paths/register',
'test/config/fixtures.ts',
], ],
spec: ['build/test/**/*.spec.js'], spec: ['test/**/*.spec.ts'],
timeout: '30000', timeout: '30000',
}; };

View File

@ -1,5 +1,5 @@
import { expect } from 'chai'; import { expect } from 'chai';
import constants = require('../src/lib/constants'); import * as constants from '~/lib/constants';
describe('constants', function () { describe('constants', function () {
it('has the correct configJsonPathOnHost', () => it('has the correct configJsonPathOnHost', () =>

View File

@ -2,9 +2,9 @@ import * as Bluebird from 'bluebird';
import * as Knex from 'knex'; import * as Knex from 'knex';
import { expect } from 'chai'; import { expect } from 'chai';
import prepare = require('./lib/prepare'); import prepare = require('~/test-lib/prepare');
import * as constants from '../src/lib/constants'; import * as constants from '~/lib/constants';
import { exists } from '../src/lib/fs-utils'; import { exists } from '~/lib/fs-utils';
async function createOldDatabase(path: string) { async function createOldDatabase(path: string) {
const knex = Knex({ const knex = Knex({
@ -49,16 +49,16 @@ describe('Database Migrations', () => {
after(() => { after(() => {
// @ts-ignore // @ts-ignore
constants.databasePath = process.env.DATABASE_PATH; constants.databasePath = process.env.DATABASE_PATH;
delete require.cache[require.resolve('../src/db')]; delete require.cache[require.resolve('~/src/db')];
}); });
it('creates a database at the path passed on creation', async () => { it('creates a database at the path passed on creation', async () => {
const databasePath = process.env.DATABASE_PATH_2!; const databasePath = process.env.DATABASE_PATH_2!;
// @ts-ignore // @ts-ignore
constants.databasePath = databasePath; constants.databasePath = databasePath;
delete require.cache[require.resolve('../src/db')]; delete require.cache[require.resolve('~/src/db')];
const testDb = await import('../src/db'); const testDb = await import('~/src/db');
await testDb.initialized; await testDb.initialized;
expect(await exists(databasePath)).to.be.true; expect(await exists(databasePath)).to.be.true;
}); });
@ -69,8 +69,8 @@ describe('Database Migrations', () => {
const knexForDB = await createOldDatabase(databasePath); const knexForDB = await createOldDatabase(databasePath);
// @ts-ignore // @ts-ignore
constants.databasePath = databasePath; constants.databasePath = databasePath;
delete require.cache[require.resolve('../src/db')]; delete require.cache[require.resolve('~/src/db')];
const testDb = await import('../src/db'); const testDb = await import('~/src/db');
await testDb.initialized; await testDb.initialized;
await Bluebird.all([ await Bluebird.all([
expect(knexForDB.schema.hasColumn('app', 'appId')).to.eventually.be.true, expect(knexForDB.schema.hasColumn('app', 'appId')).to.eventually.be.true,
@ -97,11 +97,11 @@ describe('Database Migrations', () => {
}); });
describe('Database', () => { describe('Database', () => {
let db: typeof import('../src/db'); let db: typeof import('~/src/db');
before(async () => { before(async () => {
await prepare(); await prepare();
db = await import('../src/db'); db = await import('~/src/db');
}); });
it('initializes correctly, running the migrations', () => { it('initializes correctly, running the migrations', () => {
return expect(db.initialized).to.be.fulfilled; return expect(db.initialized).to.be.fulfilled;

View File

@ -3,12 +3,12 @@ import { promises as fs } from 'fs';
import { SinonStub, stub } from 'sinon'; import { SinonStub, stub } from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import prepare = require('./lib/prepare'); import prepare = require('~/test-lib/prepare');
import * as conf from '../src/config'; import * as conf from '~/src/config';
import constants = require('../src/lib/constants'); import constants = require('~/lib/constants');
import { SchemaTypeKey } from '../src/config/schema-type'; import { SchemaTypeKey } from '~/src/config/schema-type';
import { fnSchema } from '../src/config/functions'; import { fnSchema } from '~/src/config/functions';
describe('Config', () => { describe('Config', () => {
before(async () => { before(async () => {

View File

@ -1,25 +1,22 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import { StatusCodeError, UpdatesLockedError } from '../src/lib/errors'; import { StatusCodeError, UpdatesLockedError } from '~/lib/errors';
import * as dockerUtils from '../src/lib/docker-utils'; import * as dockerUtils from '~/lib/docker-utils';
import * as config from '../src/config'; import * as config from '~/src/config';
import * as imageManager from '../src/compose/images'; import * as imageManager from '~/src/compose/images';
import { ConfigTxt } from '../src/config/backends/config-txt'; import { ConfigTxt } from '~/src/config/backends/config-txt';
import * as deviceState from '../src/device-state'; import * as deviceState from '~/src/device-state';
import * as deviceConfig from '../src/device-config'; import * as deviceConfig from '~/src/device-config';
import { import { loadTargetFromFile, appsJsonBackup } from '~/src/device-state/preload';
loadTargetFromFile, import Service from '~/src/compose/service';
appsJsonBackup, import { intialiseContractRequirements } from '~/lib/contracts';
} from '../src/device-state/preload'; import * as updateLock from '~/lib/update-lock';
import Service from '../src/compose/service'; import * as fsUtils from '~/lib/fs-utils';
import { intialiseContractRequirements } from '../src/lib/contracts'; import { TargetState } from '~/src/types';
import * as updateLock from '../src/lib/update-lock';
import * as fsUtils from '../src/lib/fs-utils';
import { TargetState } from '../src/types';
import * as dbHelper from './lib/db-helper'; import * as dbHelper from '~/test-lib/db-helper';
import log from '../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
const mockedInitialConfig = { const mockedInitialConfig = {
RESIN_SUPERVISOR_CONNECTIVITY_CHECK: 'true', RESIN_SUPERVISOR_CONNECTIVITY_CHECK: 'true',

View File

@ -8,9 +8,9 @@ import {
DeviceName, DeviceName,
NumericIdentifier, NumericIdentifier,
TargetApps, TargetApps,
} from '../src/types'; } from '~/src/types';
import * as validation from '../src/lib/validation'; import * as validation from '~/lib/validation';
describe('validation', () => { describe('validation', () => {
describe('checkBooleanish', () => { describe('checkBooleanish', () => {

View File

@ -1,8 +1,8 @@
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import { expect } from 'chai'; import { expect } from 'chai';
import blink = require('../src/lib/blink'); import blink = require('~/lib/blink');
import constants = require('../src/lib/constants'); import constants = require('~/lib/constants');
describe('blink', () => { describe('blink', () => {
it('is a blink function', () => expect(blink).to.be.a('function')); it('is a blink function', () => expect(blink).to.be.a('function'));

View File

@ -2,16 +2,16 @@ import { SinonStub, stub, spy, SinonSpy } from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import * as mixpanel from 'mixpanel'; import * as mixpanel from 'mixpanel';
import log from '../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
import supervisorVersion = require('../src/lib/supervisor-version'); import supervisorVersion = require('~/lib/supervisor-version');
import * as config from '../src/config'; import * as config from '~/src/config';
describe('EventTracker', () => { describe('EventTracker', () => {
let logEventStub: SinonStub; let logEventStub: SinonStub;
before(() => { before(() => {
logEventStub = stub(log, 'event'); logEventStub = stub(log, 'event');
delete require.cache[require.resolve('../src/event-tracker')]; delete require.cache[require.resolve('~/src/event-tracker')];
}); });
afterEach(() => { afterEach(() => {
@ -24,7 +24,7 @@ describe('EventTracker', () => {
describe('Unmanaged', () => { describe('Unmanaged', () => {
let configStub: SinonStub; let configStub: SinonStub;
let eventTracker: typeof import('../src/event-tracker'); let eventTracker: typeof import('~/src/event-tracker');
before(async () => { before(async () => {
configStub = stub(config, 'getMany').returns( configStub = stub(config, 'getMany').returns(
@ -36,13 +36,13 @@ describe('EventTracker', () => {
}) as any, }) as any,
); );
eventTracker = await import('../src/event-tracker'); eventTracker = await import('~/src/event-tracker');
}); });
after(() => { after(() => {
configStub.restore(); configStub.restore();
delete require.cache[require.resolve('../src/event-tracker')]; delete require.cache[require.resolve('~/src/event-tracker')];
}); });
it('initializes in unmanaged mode', () => { it('initializes in unmanaged mode', () => {
@ -62,7 +62,7 @@ describe('EventTracker', () => {
}); });
describe('Init', () => { describe('Init', () => {
let eventTracker: typeof import('../src/event-tracker'); let eventTracker: typeof import('~/src/event-tracker');
let configStub: SinonStub; let configStub: SinonStub;
let mixpanelSpy: SinonSpy; let mixpanelSpy: SinonSpy;
@ -78,14 +78,14 @@ describe('EventTracker', () => {
mixpanelSpy = spy(mixpanel, 'init'); mixpanelSpy = spy(mixpanel, 'init');
eventTracker = await import('../src/event-tracker'); eventTracker = await import('~/src/event-tracker');
}); });
after(() => { after(() => {
configStub.restore(); configStub.restore();
mixpanelSpy.restore(); mixpanelSpy.restore();
delete require.cache[require.resolve('../src/event-tracker')]; delete require.cache[require.resolve('~/src/event-tracker')];
}); });
it('initializes a mixpanel client when not in unmanaged mode', () => { it('initializes a mixpanel client when not in unmanaged mode', () => {
@ -100,7 +100,7 @@ describe('EventTracker', () => {
}); });
describe('Managed', () => { describe('Managed', () => {
let eventTracker: typeof import('../src/event-tracker'); let eventTracker: typeof import('~/src/event-tracker');
let configStub: SinonStub; let configStub: SinonStub;
let mixpanelStub: SinonStub; let mixpanelStub: SinonStub;
@ -119,7 +119,7 @@ describe('EventTracker', () => {
track: stub(), track: stub(),
} as any); } as any);
eventTracker = await import('../src/event-tracker'); eventTracker = await import('~/src/event-tracker');
await eventTracker.initialized; await eventTracker.initialized;
}); });
@ -127,7 +127,7 @@ describe('EventTracker', () => {
configStub.restore(); configStub.restore();
mixpanelStub.restore(); mixpanelStub.restore();
delete require.cache[require.resolve('../src/event-tracker')]; delete require.cache[require.resolve('~/src/event-tracker')];
}); });
it('calls the mixpanel client track function with the event, properties and uuid as distinct_id', async () => { it('calls the mixpanel client track function with the event, properties and uuid as distinct_id', async () => {
@ -189,21 +189,21 @@ describe('EventTracker', () => {
}); });
describe('Rate limiting', () => { describe('Rate limiting', () => {
let eventTracker: typeof import('../src/event-tracker'); let eventTracker: typeof import('~/src/event-tracker');
let mixpanelStub: SinonStub; let mixpanelStub: SinonStub;
before(async () => { before(async () => {
mixpanelStub = stub(mixpanel, 'init').returns({ mixpanelStub = stub(mixpanel, 'init').returns({
track: stub(), track: stub(),
} as any); } as any);
eventTracker = await import('../src/event-tracker'); eventTracker = await import('~/src/event-tracker');
await eventTracker.initialized; await eventTracker.initialized;
}); });
after(() => { after(() => {
mixpanelStub.restore(); mixpanelStub.restore();
delete require.cache[require.resolve('../src/event-tracker')]; delete require.cache[require.resolve('~/src/event-tracker')];
}); });
it('should rate limit events of the same type', async () => { it('should rate limit events of the same type', async () => {

View File

@ -3,8 +3,8 @@ import * as os from 'os';
import { stub, spy } from 'sinon'; import { stub, spy } from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import Log from '../src/lib/supervisor-console'; import Log from '~/lib/supervisor-console';
import * as network from '../src/network'; import * as network from '~/src/network';
describe('network', () => { describe('network', () => {
describe('getIPAddresses', () => { describe('getIPAddresses', () => {

View File

@ -4,22 +4,22 @@ import { Server } from 'net';
import { SinonSpy, SinonStub, spy, stub } from 'sinon'; import { SinonSpy, SinonStub, spy, stub } from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import prepare = require('./lib/prepare'); import prepare = require('~/test-lib/prepare');
import * as config from '../src/config'; import * as config from '~/src/config';
import * as deviceState from '../src/device-state'; import * as deviceState from '~/src/device-state';
import Log from '../src/lib/supervisor-console'; import Log from '~/lib/supervisor-console';
import balenaAPI = require('./lib/mocked-balena-api'); import balenaAPI = require('~/test-lib/mocked-balena-api');
import { schema } from '../src/config/schema'; import { schema } from '~/src/config/schema';
import ConfigJsonConfigBackend from '../src/config/configJson'; import ConfigJsonConfigBackend from '~/src/config/configJson';
import * as TargetState from '../src/device-state/target-state'; import * as TargetState from '~/src/device-state/target-state';
import * as ApiHelper from '../src/lib/api-helper'; import * as ApiHelper from '~/lib/api-helper';
import supervisorVersion = require('../src/lib/supervisor-version'); import supervisorVersion = require('~/lib/supervisor-version');
import * as eventTracker from '../src/event-tracker'; import * as eventTracker from '~/src/event-tracker';
import { TypedError } from 'typed-error'; import { TypedError } from 'typed-error';
import { DeviceNotFoundError } from '../src/lib/errors'; import { DeviceNotFoundError } from '~/lib/errors';
let ApiBinder: typeof import('../src/api-binder'); let ApiBinder: typeof import('~/src/api-binder');
class ExpectedError extends TypedError {} class ExpectedError extends TypedError {}
@ -40,7 +40,7 @@ const initModels = async (obj: Dictionary<any>, filename: string) => {
}, },
} as any; } as any;
ApiBinder = await import('../src/api-binder'); ApiBinder = await import('~/src/api-binder');
await ApiBinder.initialized; await ApiBinder.initialized;
obj.apiBinder = ApiBinder; obj.apiBinder = ApiBinder;
@ -61,7 +61,7 @@ describe('ApiBinder', () => {
let server: Server; let server: Server;
before(async () => { before(async () => {
delete require.cache[require.resolve('../src/api-binder')]; delete require.cache[require.resolve('~/src/api-binder')];
spy(balenaAPI.balenaBackend!, 'registerHandler'); spy(balenaAPI.balenaBackend!, 'registerHandler');
server = balenaAPI.listen(3000); server = balenaAPI.listen(3000);
@ -405,7 +405,7 @@ describe('ApiBinder', () => {
}); });
it('fails when stateReportHealthy is false', async () => { it('fails when stateReportHealthy is false', async () => {
const currentState = await import('../src/api-binder/report'); const currentState = await import('~/src/api-binder/report');
configStub.resolves({ configStub.resolves({
unmanaged: false, unmanaged: false,

View File

@ -5,11 +5,11 @@ import * as Promise from 'bluebird';
import { expect } from 'chai'; import { expect } from 'chai';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import { ContainerLogs } from '../src/logging/container'; import { ContainerLogs } from '~/src/logging/container';
import * as config from '../src/config'; import * as config from '~/src/config';
describe('Logger', function () { describe('Logger', function () {
let logger: typeof import('../src/logger'); let logger: typeof import('~/src/logger');
let configStub: sinon.SinonStub; let configStub: sinon.SinonStub;
beforeEach(async function () { beforeEach(async function () {
@ -36,8 +36,8 @@ describe('Logger', function () {
}), }),
); );
// delete the require cache for the logger module so we can force a refresh // delete the require cache for the logger module so we can force a refresh
delete require.cache[require.resolve('../src/logger')]; delete require.cache[require.resolve('~/src/logger')];
logger = await import('../src/logger'); logger = await import('~/src/logger');
await logger.initialized; await logger.initialized;
}); });
@ -47,7 +47,7 @@ describe('Logger', function () {
}); });
after(function () { after(function () {
delete require.cache[require.resolve('../src/logger')]; delete require.cache[require.resolve('~/src/logger')];
}); });
it('waits the grace period before sending any logs', function () { it('waits the grace period before sending any logs', function () {

View File

@ -4,19 +4,19 @@ import * as path from 'path';
import { SinonStub, stub, spy, SinonSpy, restore } from 'sinon'; import { SinonStub, stub, spy, SinonSpy, restore } from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import * as deviceConfig from '../src/device-config'; import * as deviceConfig from '~/src/device-config';
import * as fsUtils from '../src/lib/fs-utils'; import * as fsUtils from '~/lib/fs-utils';
import * as logger from '../src/logger'; import * as logger from '~/src/logger';
import { Extlinux } from '../src/config/backends/extlinux'; import { Extlinux } from '~/src/config/backends/extlinux';
import { ConfigTxt } from '../src/config/backends/config-txt'; import { ConfigTxt } from '~/src/config/backends/config-txt';
import { Odmdata } from '../src/config/backends/odmdata'; import { Odmdata } from '~/src/config/backends/odmdata';
import { ConfigFs } from '../src/config/backends/config-fs'; import { ConfigFs } from '~/src/config/backends/config-fs';
import { SplashImage } from '../src/config/backends/splash-image'; import { SplashImage } from '~/src/config/backends/splash-image';
import * as constants from '../src/lib/constants'; import * as constants from '~/lib/constants';
import log from '../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
import { fnSchema } from '../src/config/functions'; import { fnSchema } from '~/src/config/functions';
import prepare = require('./lib/prepare'); import prepare = require('~/test-lib/prepare');
import mock = require('mock-fs'); import mock = require('mock-fs');
const extlinuxBackend = new Extlinux(); const extlinuxBackend = new Extlinux();

View File

@ -1,5 +1,5 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as conversion from '../src/lib/conversions'; import * as conversion from '~/lib/conversions';
describe('conversions', function () { describe('conversions', function () {
describe('envArrayToObject', function () { describe('envArrayToObject', function () {

View File

@ -1,4 +1,4 @@
import { PortMap, PortRange } from '../src/compose/ports'; import { PortMap, PortRange } from '~/src/compose/ports';
import { expect } from 'chai'; import { expect } from 'chai';
// Force cast `PortMap` as a public version so we can test it // Force cast `PortMap` as a public version so we can test it
@ -298,8 +298,8 @@ describe('Ports', function () {
describe('Running container comparison', () => describe('Running container comparison', () =>
it('should not consider order when comparing current and target state', function () { it('should not consider order when comparing current and target state', function () {
const portBindings = require('./data/ports/not-ascending/port-bindings.json'); const portBindings = require('~/test-data/ports/not-ascending/port-bindings.json');
const compose = require('./data/ports/not-ascending/compose.json'); const compose = require('~/test-data/ports/not-ascending/compose.json');
const portMapsCurrent = PortMap.fromDockerOpts(portBindings); const portMapsCurrent = PortMap.fromDockerOpts(portBindings);
const portMapsTarget = PortMap.fromComposePorts(compose.ports); const portMapsTarget = PortMap.fromComposePorts(compose.ports);

View File

@ -2,14 +2,14 @@ import { stub } from 'sinon';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { expect } from 'chai'; import { expect } from 'chai';
import * as config from '../src/config'; import * as config from '~/src/config';
import * as configUtils from '../src/config/utils'; import * as configUtils from '~/src/config/utils';
import { ExtraUEnv } from '../src/config/backends/extra-uEnv'; import { ExtraUEnv } from '~/src/config/backends/extra-uEnv';
import { Extlinux } from '../src/config/backends/extlinux'; import { Extlinux } from '~/src/config/backends/extlinux';
import { ConfigTxt } from '../src/config/backends/config-txt'; import { ConfigTxt } from '~/src/config/backends/config-txt';
import { ConfigFs } from '../src/config/backends/config-fs'; import { ConfigFs } from '~/src/config/backends/config-fs';
import { SplashImage } from '../src/config/backends/splash-image'; import { SplashImage } from '~/src/config/backends/splash-image';
import { ConfigBackend } from '../src/config/backends/backend'; import { ConfigBackend } from '~/src/config/backends/backend';
describe('Config Utilities', () => { describe('Config Utilities', () => {
it('gets list of supported backends', async () => { it('gets list of supported backends', async () => {

View File

@ -2,12 +2,12 @@ import { SinonStub, stub } from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as apiBinder from '../src/api-binder'; import * as apiBinder from '~/src/api-binder';
import * as applicationManager from '../src/compose/application-manager'; import * as applicationManager from '~/src/compose/application-manager';
import * as deviceState from '../src/device-state'; import * as deviceState from '~/src/device-state';
import * as constants from '../src/lib/constants'; import * as constants from '~/src/lib/constants';
import { docker } from '../src/lib/docker-utils'; import { docker } from '~/lib/docker-utils';
import { Supervisor } from '../src/supervisor'; import { Supervisor } from '~/src/supervisor';
describe('Startup', () => { describe('Startup', () => {
let startStub: SinonStub; let startStub: SinonStub;

View File

@ -1,5 +1,5 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as ComposeUtils from '../src/compose/utils'; import * as ComposeUtils from '~/src/compose/utils';
describe('Composition utilities', () => describe('Composition utilities', () =>
it('Should correctly camel case the configuration', function () { it('Should correctly camel case the configuration', function () {

View File

@ -2,14 +2,14 @@ import { expect } from 'chai';
import { spy } from 'sinon'; import { spy } from 'sinon';
import * as supertest from 'supertest'; import * as supertest from 'supertest';
import mockedAPI = require('./lib/mocked-device-api'); import mockedAPI = require('~/test-lib/mocked-device-api');
import * as apiBinder from '../src/api-binder'; import * as apiBinder from '~/src/api-binder';
import * as deviceState from '../src/device-state'; import * as deviceState from '~/src/device-state';
import Log from '../src/lib/supervisor-console'; import Log from '~/lib/supervisor-console';
import SupervisorAPI from '../src/supervisor-api'; import SupervisorAPI from '~/src/supervisor-api';
import * as apiKeys from '../src/lib/api-keys'; import * as apiKeys from '~/lib/api-keys';
import * as db from '../src/db'; import * as db from '~/src/db';
import { cloudApiKey } from '../src/lib/api-keys'; import { cloudApiKey } from '~/lib/api-keys';
const mockedOptions = { const mockedOptions = {
listenPort: 54321, listenPort: 54321,

View File

@ -2,13 +2,13 @@ import { expect } from 'chai';
import * as Docker from 'dockerode'; import * as Docker from 'dockerode';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import * as db from '../src/db'; import * as db from '~/src/db';
import { docker } from '../src/lib/docker-utils'; import { docker } from '~/lib/docker-utils';
import LocalModeManager, { import LocalModeManager, {
EngineSnapshot, EngineSnapshot,
EngineSnapshotRecord, EngineSnapshotRecord,
} from '../src/local-mode'; } from '~/src/local-mode';
import ShortStackError from './lib/errors'; import ShortStackError from '~/test-lib/errors';
describe('LocalModeManager', () => { describe('LocalModeManager', () => {
let localMode: LocalModeManager; let localMode: LocalModeManager;

View File

@ -2,15 +2,15 @@ import { expect } from 'chai';
import { SinonStub, stub } from 'sinon'; import { SinonStub, stub } from 'sinon';
import * as semver from 'semver'; import * as semver from 'semver';
import * as constants from '../src/lib/constants'; import * as constants from '~/lib/constants';
import { import {
containerContractsFulfilled, containerContractsFulfilled,
intialiseContractRequirements, intialiseContractRequirements,
validateContract, validateContract,
} from '../src/lib/contracts'; } from '~/lib/contracts';
import * as osRelease from '../src/lib/os-release'; import * as osRelease from '~/lib/os-release';
import supervisorVersion = require('../src/lib/supervisor-version'); import supervisorVersion = require('~/lib/supervisor-version');
import * as fsUtils from '../src/lib/fs-utils'; import * as fsUtils from '~/lib/fs-utils';
describe('Container contracts', () => { describe('Container contracts', () => {
before(() => { before(() => {

View File

@ -1,7 +1,7 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { stub } from 'sinon'; import { stub } from 'sinon';
import * as dockerUtils from '../src/lib/docker-utils'; import * as dockerUtils from '~/lib/docker-utils';
describe('Deltas', () => { describe('Deltas', () => {
it('should correctly detect a V2 delta', async () => { it('should correctly detect a V2 delta', async () => {

View File

@ -1,8 +1,8 @@
import { SinonStub, stub } from 'sinon'; import { SinonStub, stub } from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import constants = require('../src/lib/constants'); import constants = require('~/lib/constants');
import { spawnJournalctl } from '../src/lib/journald'; import { spawnJournalctl } from '~/lib/journald';
describe('journald', () => { describe('journald', () => {
let spawn: SinonStub; let spawn: SinonStub;

View File

@ -3,8 +3,8 @@ import { stripIndent } from 'common-tags';
import { SinonStub, stub } from 'sinon'; import { SinonStub, stub } from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import * as fsUtils from '../src/lib/fs-utils'; import * as fsUtils from '~/lib/fs-utils';
import { Extlinux } from '../src/config/backends/extlinux'; import { Extlinux } from '~/src/config/backends/extlinux';
describe('Extlinux Configuration', () => { describe('Extlinux Configuration', () => {
const backend = new Extlinux(); const backend = new Extlinux();

View File

@ -1,13 +1,13 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { isRight } from 'fp-ts/lib/Either'; import { isRight } from 'fp-ts/lib/Either';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import App from '../src/compose/app'; import App from '~/src/compose/app';
import Network from '../src/compose/network'; import Network from '~/src/compose/network';
import * as config from '../src/config'; import * as config from '~/src/config';
import * as dbFormat from '../src/device-state/db-format'; import * as dbFormat from '~/src/device-state/db-format';
import log from '../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
import { TargetApps } from '../src/types/state'; import { TargetApps } from '~/src/types/state';
import * as dbHelper from './lib/db-helper'; import * as dbHelper from '~/test-lib/db-helper';
function getDefaultNetwork(appId: number) { function getDefaultNetwork(appId: number) {
return { return {

View File

@ -1,5 +1,5 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { AppendDirective } from '../src/config/backends/extlinux-file'; import { AppendDirective } from '~/src/config/backends/extlinux-file';
describe('APPEND directive', () => { describe('APPEND directive', () => {
const supportedConfigValues = ['isolcpus']; const supportedConfigValues = ['isolcpus'];

View File

@ -1,5 +1,5 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { FDTDirective } from '../src/config/backends/extlinux-file'; import { FDTDirective } from '~/src/config/backends/extlinux-file';
describe('FDT directive', () => { describe('FDT directive', () => {
const directive = new FDTDirective(); const directive = new FDTDirective();

View File

@ -1,7 +1,7 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { testWithData } from './lib/mocked-dockerode'; import { testWithData } from '~/test-lib/mocked-dockerode';
import * as dockerUtils from '../src/lib/docker-utils'; import * as dockerUtils from '~/lib/docker-utils';
describe('Docker Utils', () => { describe('Docker Utils', () => {
describe('Supervisor Address', () => { describe('Supervisor Address', () => {

View File

@ -3,9 +3,9 @@ import { stripIndent } from 'common-tags';
import { SinonStub, spy, stub } from 'sinon'; import { SinonStub, spy, stub } from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import * as fsUtils from '../src/lib/fs-utils'; import * as fsUtils from '~/lib/fs-utils';
import Log from '../src/lib/supervisor-console'; import Log from '~/lib/supervisor-console';
import { ExtraUEnv } from '../src/config/backends/extra-uEnv'; import { ExtraUEnv } from '~/src/config/backends/extra-uEnv';
describe('extra_uEnv Configuration', () => { describe('extra_uEnv Configuration', () => {
const backend = new ExtraUEnv(); const backend = new ExtraUEnv();

View File

@ -2,18 +2,18 @@ import _ = require('lodash');
import { expect } from 'chai'; import { expect } from 'chai';
import * as Docker from 'dockerode'; import * as Docker from 'dockerode';
import { docker } from '../src/lib/docker-utils'; import { docker } from '~/lib/docker-utils';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import * as config from '../src/config'; import * as config from '~/src/config';
import * as firewall from '../src/lib/firewall'; import * as firewall from '~/lib/firewall';
import * as logger from '../src/logger'; import * as logger from '~/src/logger';
import * as iptablesMock from './lib/mocked-iptables'; import * as iptablesMock from '~/test-lib/mocked-iptables';
import * as targetStateCache from '../src/device-state/target-state-cache'; import * as targetStateCache from '~/src/device-state/target-state-cache';
import constants = require('../src/lib/constants'); import constants = require('~/lib/constants');
import { RuleAction, Rule } from '../src/lib/iptables'; import { RuleAction, Rule } from '~/lib/iptables';
import { log } from '../src/lib/supervisor-console'; import { log } from '~/lib/supervisor-console';
describe('Host Firewall', function () { describe('Host Firewall', function () {
const dockerStubs: Dictionary<sinon.SinonStub> = {}; const dockerStubs: Dictionary<sinon.SinonStub> = {};

View File

@ -1,6 +1,6 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as osRelease from '../src/lib/os-release'; import * as osRelease from '~/lib/os-release';
const OS_RELEASE_PATH = 'test/data/etc/os-release-tx2'; const OS_RELEASE_PATH = 'test/data/etc/os-release-tx2';

View File

@ -3,8 +3,8 @@ import { promises as fs } from 'fs';
import { resolve } from 'path'; import { resolve } from 'path';
import { expect } from 'chai'; import { expect } from 'chai';
import Log from '../src/lib/supervisor-console'; import Log from '~/lib/supervisor-console';
import { Odmdata } from '../src/config/backends/odmdata'; import { Odmdata } from '~/src/config/backends/odmdata';
describe('ODMDATA Configuration', () => { describe('ODMDATA Configuration', () => {
const backend = new Odmdata(); const backend = new Odmdata();
@ -12,7 +12,7 @@ describe('ODMDATA Configuration', () => {
let logErrorStub: SinonStub; let logErrorStub: SinonStub;
// @ts-ignore accessing private vluae // @ts-ignore accessing private vluae
const previousConfigPath = Odmdata.bootConfigPath; const previousConfigPath = Odmdata.bootConfigPath;
const testConfigPath = resolve(__dirname, 'data/boot0.img'); const testConfigPath = resolve(process.cwd(), 'test/data/boot0.img');
before(() => { before(() => {
// @ts-ignore setting value of private variable // @ts-ignore setting value of private variable

View File

@ -1,7 +1,7 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as commitStore from '../src/compose/commit'; import * as commitStore from '~/src/compose/commit';
import * as db from '../src/db'; import * as db from '~/src/db';
describe('compose/commit', () => { describe('compose/commit', () => {
before(async () => await db.initialized); before(async () => await db.initialized);

View File

@ -4,14 +4,14 @@ import * as _ from 'lodash';
import rewire = require('rewire'); import rewire = require('rewire');
import { expect } from 'chai'; import { expect } from 'chai';
import { sleep } from './lib/helpers'; import { sleep } from '~/test-lib/helpers';
import * as TargetState from '../src/device-state/target-state'; import * as TargetState from '~/src/device-state/target-state';
import Log from '../src/lib/supervisor-console'; import Log from '~/lib/supervisor-console';
import * as request from '../src/lib/request'; import * as request from '~/lib/request';
import * as deviceConfig from '../src/device-config'; import * as deviceConfig from '~/src/device-config';
import { UpdatesLockedError } from '../src/lib/errors'; import { UpdatesLockedError } from '~/lib/errors';
const deviceState = rewire('../src/device-state'); const deviceState = rewire('~/src/device-state');
const stateEndpointBody = { const stateEndpointBody = {
local: { local: {

View File

@ -13,29 +13,29 @@ import * as supertest from 'supertest';
import * as path from 'path'; import * as path from 'path';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import { exists, unlinkAll } from '../src/lib/fs-utils'; import { exists, unlinkAll } from '~/lib/fs-utils';
import * as appMock from './lib/application-state-mock'; import * as appMock from '~/test-lib/application-state-mock';
import * as mockedDockerode from './lib/mocked-dockerode'; import * as mockedDockerode from '~/test-lib/mocked-dockerode';
import mockedAPI = require('./lib/mocked-device-api'); import mockedAPI = require('~/test-lib/mocked-device-api');
import sampleResponses = require('./data/device-api-responses.json'); import sampleResponses = require('~/test-data/device-api-responses.json');
import * as config from '../src/config'; import * as config from '~/src/config';
import * as logger from '../src/logger'; import * as logger from '~/src/logger';
import SupervisorAPI from '../src/supervisor-api'; import SupervisorAPI from '~/src/supervisor-api';
import * as apiBinder from '../src/api-binder'; import * as apiBinder from '~/src/api-binder';
import * as deviceState from '../src/device-state'; import * as deviceState from '~/src/device-state';
import * as apiKeys from '../src/lib/api-keys'; import * as apiKeys from '~/lib/api-keys';
import * as dbus from '../src/lib/dbus'; import * as dbus from '~/lib/dbus';
import * as updateLock from '../src/lib/update-lock'; import * as updateLock from '~/lib/update-lock';
import * as TargetState from '../src/device-state/target-state'; import * as TargetState from '~/src/device-state/target-state';
import * as targetStateCache from '../src/device-state/target-state-cache'; import * as targetStateCache from '~/src/device-state/target-state-cache';
import blink = require('../src/lib/blink'); import blink = require('~/lib/blink');
import constants = require('../src/lib/constants'); import constants = require('~/lib/constants');
import * as deviceAPI from '../src/device-api/common'; import * as deviceAPI from '~/src/device-api/common';
import { UpdatesLockedError } from '../src/lib/errors'; import { UpdatesLockedError } from '~/lib/errors';
import { SchemaTypeKey } from '../src/config/schema-type'; import { SchemaTypeKey } from '~/src/config/schema-type';
import log from '../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
import * as applicationManager from '../src/compose/application-manager'; import * as applicationManager from '~/src/compose/application-manager';
import App from '../src/compose/app'; import App from '~/src/compose/app';
describe('SupervisorAPI [V1 Endpoints]', () => { describe('SupervisorAPI [V1 Endpoints]', () => {
let api: SupervisorAPI; let api: SupervisorAPI;

View File

@ -3,22 +3,22 @@ import { stub, SinonStub, spy, SinonSpy } from 'sinon';
import * as supertest from 'supertest'; import * as supertest from 'supertest';
import * as Bluebird from 'bluebird'; import * as Bluebird from 'bluebird';
import sampleResponses = require('./data/device-api-responses.json'); import sampleResponses = require('~/test-data/device-api-responses.json');
import mockedAPI = require('./lib/mocked-device-api'); import mockedAPI = require('~/test-lib/mocked-device-api');
import * as apiBinder from '../src/api-binder'; import * as apiBinder from '~/src/api-binder';
import * as deviceState from '../src/device-state'; import * as deviceState from '~/src/device-state';
import SupervisorAPI from '../src/supervisor-api'; import SupervisorAPI from '~/src/supervisor-api';
import * as serviceManager from '../src/compose/service-manager'; import * as serviceManager from '~/src/compose/service-manager';
import * as images from '../src/compose/images'; import * as images from '~/src/compose/images';
import * as apiKeys from '../src/lib/api-keys'; import * as apiKeys from '~/lib/api-keys';
import * as config from '../src/config'; import * as config from '~/src/config';
import * as updateLock from '../src/lib/update-lock'; import * as updateLock from '~/lib/update-lock';
import * as targetStateCache from '../src/device-state/target-state-cache'; import * as targetStateCache from '~/src/device-state/target-state-cache';
import * as mockedDockerode from './lib/mocked-dockerode'; import * as mockedDockerode from '~/test-lib/mocked-dockerode';
import * as applicationManager from '../src/compose/application-manager'; import * as applicationManager from '~/src/compose/application-manager';
import * as logger from '../src/logger'; import * as logger from '~/src/logger';
import { UpdatesLockedError } from '../src/lib/errors'; import { UpdatesLockedError } from '~/lib/errors';
describe('SupervisorAPI [V2 Endpoints]', () => { describe('SupervisorAPI [V2 Endpoints]', () => {
let serviceManagerMock: SinonStub; let serviceManagerMock: SinonStub;

View File

@ -2,9 +2,9 @@ import { promises as fs } from 'fs';
import { SinonStub, stub } from 'sinon'; import { SinonStub, stub } from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import * as fsUtils from '../src/lib/fs-utils'; import * as fsUtils from '~/lib/fs-utils';
import { SplashImage } from '../src/config/backends/splash-image'; import { SplashImage } from '~/src/config/backends/splash-image';
import log from '../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
describe('Splash image configuration', () => { describe('Splash image configuration', () => {
const backend = new SplashImage(); const backend = new SplashImage();

View File

@ -57,6 +57,6 @@ fs.writeFileSync(
fs.readFileSync('./test/data/testconfig.json'), fs.readFileSync('./test/data/testconfig.json'),
); );
import '../lib/mocked-dbus'; import '~/test-lib/mocked-dbus';
import '../lib/mocked-dockerode'; import '~/test-lib/mocked-dockerode';
import '../lib/mocked-iptables'; import '~/test-lib/mocked-iptables';

View File

@ -1,11 +1,11 @@
import * as networkManager from '../../src/compose/network-manager'; import * as networkManager from '~/src/compose/network-manager';
import * as volumeManager from '../../src/compose/volume-manager'; import * as volumeManager from '~/src/compose/volume-manager';
import * as serviceManager from '../../src/compose/service-manager'; import * as serviceManager from '~/src/compose/service-manager';
import * as imageManager from '../../src/compose/images'; import * as imageManager from '~/src/compose/images';
import Service from '../../src/compose/service'; import Service from '~/src/compose/service';
import Network from '../../src/compose/network'; import Network from '~/src/compose/network';
import Volume from '../../src/compose/volume'; import Volume from '~/src/compose/volume';
const originalVolGetAll = volumeManager.getAll; const originalVolGetAll = volumeManager.getAll;
const originalSvcGetAll = serviceManager.getAll; const originalSvcGetAll = serviceManager.getAll;

View File

@ -1,5 +1,5 @@
import * as constants from '../../src/lib/constants'; import * as constants from '~/lib/constants';
import * as db from '../../src/db'; import * as db from '~/src/db';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
// Creates a test database and returns a query builder // Creates a test database and returns a query builder
@ -13,7 +13,7 @@ export async function createDB() {
constants.databasePath = process.env.DATABASE_PATH; constants.databasePath = process.env.DATABASE_PATH;
// Cleanup the module cache in order to have it reloaded in the local context // Cleanup the module cache in order to have it reloaded in the local context
delete require.cache[require.resolve('../../src/db')]; delete require.cache[require.resolve('~/src/db')];
// Initialize the database module // Initialize the database module
await db.initialized; await db.initialized;
@ -76,7 +76,7 @@ export async function createDB() {
// Cleanup the module cache in order to have it reloaded // Cleanup the module cache in order to have it reloaded
// correctly next time it's used // correctly next time it's used
delete require.cache[require.resolve('../../src/db')]; delete require.cache[require.resolve('~/src/db')];
}, },
}; };
} }

View File

@ -2,8 +2,8 @@ import * as _ from 'lodash';
import { SinonStub, stub } from 'sinon'; import { SinonStub, stub } from 'sinon';
import { QueryBuilder } from 'knex'; import { QueryBuilder } from 'knex';
import * as db from '../../src/db'; import * as db from '~/src/db';
import { Image } from '../../src/compose/images'; import { Image } from '~/src/compose/images';
let modelStub: SinonStub | null = null; let modelStub: SinonStub | null = null;
// MOCKED MODELS // MOCKED MODELS

View File

@ -2,21 +2,21 @@ import * as _ from 'lodash';
import { Router } from 'express'; import { Router } from 'express';
import rewire = require('rewire'); import rewire = require('rewire');
import { unlinkAll } from '../../src/lib/fs-utils'; import { unlinkAll } from '~/lib/fs-utils';
import * as applicationManager from '../../src/compose/application-manager'; import * as applicationManager from '~/src/compose/application-manager';
import * as serviceManager from '../../src/compose/service-manager'; import * as serviceManager from '~/src/compose/service-manager';
import * as volumeManager from '../../src/compose/volume-manager'; import * as volumeManager from '~/src/compose/volume-manager';
import * as commitStore from '../../src/compose/commit'; import * as commitStore from '~/src/compose/commit';
import * as config from '../../src/config'; import * as config from '~/src/config';
import * as db from '../../src/db'; import * as db from '~/src/db';
import { createV1Api } from '../../src/device-api/v1'; import { createV1Api } from '~/src/device-api/v1';
import { createV2Api } from '../../src/device-api/v2'; import { createV2Api } from '~/src/device-api/v2';
import * as deviceState from '../../src/device-state'; import * as deviceState from '~/src/device-state';
import SupervisorAPI from '../../src/supervisor-api'; import SupervisorAPI from '~/src/supervisor-api';
import { Service } from '../../src/compose/service'; import { Service } from '~/src/compose/service';
import { Image } from '../../src/compose/images'; import { Image } from '~/src/compose/images';
const apiBinder = rewire('../../src/api-binder'); const apiBinder = rewire('~/src/api-binder');
const DB_PATH = './test/data/supervisor-api.sqlite'; const DB_PATH = './test/data/supervisor-api.sqlite';

View File

@ -3,8 +3,8 @@ import { expect } from 'chai';
import { stub } from 'sinon'; import { stub } from 'sinon';
import * as childProcess from 'child_process'; import * as childProcess from 'child_process';
import * as firewall from '../../src/lib/firewall'; import * as firewall from '~/lib/firewall';
import * as iptables from '../../src/lib/iptables'; import * as iptables from '~/lib/iptables';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { Writable } from 'stream'; import { Writable } from 'stream';

View File

@ -1,6 +1,6 @@
import * as fs from 'fs'; import * as fs from 'fs';
import * as db from '../../src/db'; import * as db from '~/src/db';
import * as config from '../../src/config'; import * as config from '~/src/config';
export = async function () { export = async function () {
await db.initialized; await db.initialized;

View File

@ -1,16 +1,16 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import App from '../../../src/compose/app'; import App from '~/src/compose/app';
import { import {
CompositionStep, CompositionStep,
CompositionStepAction, CompositionStepAction,
} from '../../../src/compose/composition-steps'; } from '~/src/compose/composition-steps';
import { Image } from '../../../src/compose/images'; import { Image } from '~/src/compose/images';
import Network from '../../../src/compose/network'; import Network from '~/src/compose/network';
import Service from '../../../src/compose/service'; import Service from '~/src/compose/service';
import { ServiceComposeConfig } from '../../../src/compose/types/service'; import { ServiceComposeConfig } from '~/src/compose/types/service';
import Volume from '../../../src/compose/volume'; import Volume from '~/src/compose/volume';
import log from '../../../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
const defaultContext = { const defaultContext = {
localMode: false, localMode: false,

View File

@ -1,20 +1,20 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import { stub } from 'sinon'; import { stub } from 'sinon';
import App from '../../../src/compose/app'; import App from '~/src/compose/app';
import * as applicationManager from '../../../src/compose/application-manager'; import * as applicationManager from '~/src/compose/application-manager';
import * as imageManager from '../../../src/compose/images'; import * as imageManager from '~/src/compose/images';
import * as serviceManager from '../../../src/compose/service-manager'; import * as serviceManager from '~/src/compose/service-manager';
import { Image } from '../../../src/compose/images'; import { Image } from '~/src/compose/images';
import Network from '../../../src/compose/network'; import Network from '~/src/compose/network';
import * as networkManager from '../../../src/compose/network-manager'; import * as networkManager from '~/src/compose/network-manager';
import Service from '../../../src/compose/service'; import Service from '~/src/compose/service';
import { ServiceComposeConfig } from '../../../src/compose/types/service'; import { ServiceComposeConfig } from '~/src/compose/types/service';
import Volume from '../../../src/compose/volume'; import Volume from '~/src/compose/volume';
import log from '../../../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
import { InstancedAppState } from '../../../src/types/state'; import { InstancedAppState } from '~/src/types/state';
import * as dbHelper from '../../lib/db-helper'; import * as dbHelper from '~/test-lib/db-helper';
const DEFAULT_NETWORK = Network.fromComposeObject('default', 1, 'appuuid', {}); const DEFAULT_NETWORK = Network.fromComposeObject('default', 1, 'appuuid', {});

View File

@ -1,11 +1,11 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as imageManager from '../../../src/compose/images'; import * as imageManager from '~/src/compose/images';
import * as dbHelper from '../../lib/db-helper'; import * as dbHelper from '~/test-lib/db-helper';
import { createImage, withMockerode } from '../../lib/mockerode'; import { createImage, withMockerode } from '~/test-lib/mockerode';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import log from '../../../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
// TODO: this code is duplicated in multiple tests // TODO: this code is duplicated in multiple tests
// create a test module with all helper functions like this // create a test module with all helper functions like this

View File

@ -1,11 +1,11 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import { Network } from '../../../src/compose/network'; import { Network } from '~/src/compose/network';
import { NetworkInspectInfo } from 'dockerode'; import { NetworkInspectInfo } from 'dockerode';
import { createNetwork, withMockerode } from '../../lib/mockerode'; import { createNetwork, withMockerode } from '~/test-lib/mockerode';
import { log } from '../../../src/lib/supervisor-console'; import { log } from '~/lib/supervisor-console';
describe('compose/network', () => { describe('compose/network', () => {
describe('creating a network from a compose object', () => { describe('creating a network from a compose object', () => {

View File

@ -2,31 +2,31 @@ import * as _ from 'lodash';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import { expect } from 'chai'; import { expect } from 'chai';
import { createContainer } from '../../lib/mockerode'; import { createContainer } from '~/test-lib/mockerode';
import Service from '../../../src/compose/service'; import Service from '~/src/compose/service';
import Volume from '../../../src/compose/volume'; import Volume from '~/src/compose/volume';
import * as ServiceT from '../../../src/compose/types/service'; import * as ServiceT from '~/src/compose/types/service';
import * as constants from '../../../src/lib/constants'; import * as constants from '~/lib/constants';
import * as apiKeys from '../../../src/lib/api-keys'; import * as apiKeys from '~/lib/api-keys';
import log from '../../../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
const configs = { const configs = {
simple: { simple: {
compose: require('../../data/docker-states/simple/compose.json'), compose: require('~/test-data/docker-states/simple/compose.json'),
imageInfo: require('../../data/docker-states/simple/imageInfo.json'), imageInfo: require('~/test-data/docker-states/simple/imageInfo.json'),
inspect: require('../../data/docker-states/simple/inspect.json'), inspect: require('~/test-data/docker-states/simple/inspect.json'),
}, },
entrypoint: { entrypoint: {
compose: require('../../data/docker-states/entrypoint/compose.json'), compose: require('~/test-data/docker-states/entrypoint/compose.json'),
imageInfo: require('../../data/docker-states/entrypoint/imageInfo.json'), imageInfo: require('~/test-data/docker-states/entrypoint/imageInfo.json'),
inspect: require('../../data/docker-states/entrypoint/inspect.json'), inspect: require('~/test-data/docker-states/entrypoint/inspect.json'),
}, },
networkModeService: { networkModeService: {
compose: require('../../data/docker-states/network-mode-service/compose.json'), compose: require('~/test-data/docker-states/network-mode-service/compose.json'),
imageInfo: require('../../data/docker-states/network-mode-service/imageInfo.json'), imageInfo: require('~/test-data/docker-states/network-mode-service/imageInfo.json'),
inspect: require('../../data/docker-states/network-mode-service/inspect.json'), inspect: require('~/test-data/docker-states/network-mode-service/inspect.json'),
}, },
}; };

View File

@ -5,10 +5,10 @@ import {
createVolume, createVolume,
createContainer, createContainer,
withMockerode, withMockerode,
} from '../../lib/mockerode'; } from '~/test-lib/mockerode';
import * as volumeManager from '../../../src/compose/volume-manager'; import * as volumeManager from '~/src/compose/volume-manager';
import log from '../../../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
import Volume from '../../../src/compose/volume'; import Volume from '~/src/compose/volume';
describe('compose/volume-manager', () => { describe('compose/volume-manager', () => {
describe('Retrieving volumes from the engine', () => { describe('Retrieving volumes from the engine', () => {

View File

@ -1,10 +1,10 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { SinonStub, stub } from 'sinon'; import { SinonStub, stub } from 'sinon';
import Volume from '../../../src/compose/volume'; import Volume from '~/src/compose/volume';
import * as logTypes from '../../../src/lib/log-types'; import * as logTypes from '~/lib/log-types';
import * as logger from '../../../src/logger'; import * as logger from '~/src/logger';
import { createVolume, withMockerode } from '../../lib/mockerode'; import { createVolume, withMockerode } from '~/test-lib/mockerode';
describe('compose/volume', () => { describe('compose/volume', () => {
describe('creating a volume from a compose object', () => { describe('creating a volume from a compose object', () => {

View File

@ -1,8 +1,8 @@
import { assert, expect } from 'chai'; import { assert, expect } from 'chai';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import { StatusError } from '../../../src/lib/errors'; import { StatusError } from '~/lib/errors';
import { withBackoff, OnFailureInfo } from '../../../src/lib/backoff'; import { withBackoff, OnFailureInfo } from '~/lib/backoff';
const DEFAULT_OPTIONS = { const DEFAULT_OPTIONS = {
maxRetries: 5, maxRetries: 5,

View File

@ -4,8 +4,8 @@ import { promises as fs } from 'fs';
import { spy, SinonSpy } from 'sinon'; import { spy, SinonSpy } from 'sinon';
import mock = require('mock-fs'); import mock = require('mock-fs');
import * as fsUtils from '../../../src/lib/fs-utils'; import * as fsUtils from '~/lib/fs-utils';
import { rootMountPoint } from '../../../src/lib/constants'; import { rootMountPoint } from '~/lib/constants';
describe('lib/fs-utils', () => { describe('lib/fs-utils', () => {
const testFileName1 = 'file.1'; const testFileName1 = 'file.1';

View File

@ -1,5 +1,5 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { equals, diff, prune, shallowDiff } from '../../../src/lib/json'; import { equals, diff, prune, shallowDiff } from '~/lib/json';
describe('JSON utils', () => { describe('JSON utils', () => {
describe('equals', () => { describe('equals', () => {

View File

@ -3,10 +3,10 @@ import { isRight } from 'fp-ts/lib/Either';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
import * as nock from 'nock'; import * as nock from 'nock';
import { TargetState } from '../../../src/types'; import { TargetState } from '~/src/types';
import * as config from '../../../src/config'; import * as config from '~/src/config';
import * as legacy from '../../../src/lib/legacy'; import * as legacy from '~/lib/legacy';
import log from '../../../src/lib/supervisor-console'; import log from '~/lib/supervisor-console';
describe('lib/legacy', () => { describe('lib/legacy', () => {
before(async () => { before(async () => {

View File

@ -4,9 +4,9 @@ import { stub, SinonStub } from 'sinon';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import mock = require('mock-fs'); import mock = require('mock-fs');
import * as lockfile from '../../../src/lib/lockfile'; import * as lockfile from '~/lib/lockfile';
import * as fsUtils from '../../../src/lib/fs-utils'; import * as fsUtils from '~/lib/fs-utils';
import { BASE_LOCK_DIR, LOCKFILE_UID } from '../../../src/lib/update-lock'; import { BASE_LOCK_DIR, LOCKFILE_UID } from '~/lib/update-lock';
describe('lib/lockfile', () => { describe('lib/lockfile', () => {
const lockPath = `${BASE_LOCK_DIR}/1234567/one/updates.lock`; const lockPath = `${BASE_LOCK_DIR}/1234567/one/updates.lock`;

View File

@ -3,8 +3,8 @@ import { SinonStub, stub } from 'sinon';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import * as systeminformation from 'systeminformation'; import * as systeminformation from 'systeminformation';
import * as fsUtils from '../../../src/lib/fs-utils'; import * as fsUtils from '~/lib/fs-utils';
import * as sysInfo from '../../../src/lib/system-info'; import * as sysInfo from '~/lib/system-info';
describe('System information', () => { describe('System information', () => {
before(() => { before(() => {

View File

@ -4,12 +4,12 @@ import * as path from 'path';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import mockFs = require('mock-fs'); import mockFs = require('mock-fs');
import * as updateLock from '../../../src/lib/update-lock'; import * as updateLock from '~/lib/update-lock';
import * as constants from '../../../src/lib/constants'; import * as constants from '~/lib/constants';
import { UpdatesLockedError } from '../../../src/lib/errors'; import { UpdatesLockedError } from '~/lib/errors';
import * as config from '../../../src/config'; import * as config from '~/src/config';
import * as lockfile from '../../../src/lib/lockfile'; import * as lockfile from '~/lib/lockfile';
import * as fsUtils from '../../../src/lib/fs-utils'; import * as fsUtils from '~/lib/fs-utils';
describe('lib/update-lock', () => { describe('lib/update-lock', () => {
const appId = 1234567; const appId = 1234567;

View File

@ -1,5 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"baseUrl": "./",
"target": "ES2019", "target": "ES2019",
"module": "commonjs", "module": "commonjs",
"strict": true, "strict": true,
@ -11,7 +12,13 @@
"skipLibCheck": true, "skipLibCheck": true,
"lib": ["es2019"], "lib": ["es2019"],
"resolveJsonModule": true, "resolveJsonModule": true,
"allowJs": true "allowJs": true,
"paths": {
"~/src/*": ["src/*"],
"~/lib/*": ["src/lib/*"],
"~/test-lib/*": ["test/lib/*"],
"~/test-data/*": ["test/data/*"]
}
}, },
"include": ["src/**/*", "test/**/*", "typings/**/*.d.ts"] "include": ["src/**/*", "test/**/*", "typings/**/*.d.ts"]
} }