@iobroker/testing 4.1.3 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/build/index.d.ts +1 -1
  4. package/build/lib/adapterTools.d.ts +7 -2
  5. package/build/lib/adapterTools.js +47 -31
  6. package/build/lib/executeCommand.d.ts +3 -3
  7. package/build/lib/executeCommand.js +32 -32
  8. package/build/lib/str2regex.js +5 -6
  9. package/build/lib/testAdapter.d.ts +1 -0
  10. package/build/lib/testAdapter.js +1 -0
  11. package/build/tests/index.d.ts +9 -9
  12. package/build/tests/index.js +0 -1
  13. package/build/tests/integration/index.d.ts +1 -3
  14. package/build/tests/integration/index.js +46 -41
  15. package/build/tests/integration/lib/adapterSetup.d.ts +1 -1
  16. package/build/tests/integration/lib/adapterSetup.js +55 -42
  17. package/build/tests/integration/lib/controllerSetup.d.ts +1 -10
  18. package/build/tests/integration/lib/controllerSetup.js +59 -56
  19. package/build/tests/integration/lib/dbConnection.d.ts +12 -16
  20. package/build/tests/integration/lib/dbConnection.js +71 -69
  21. package/build/tests/integration/lib/harness.d.ts +9 -12
  22. package/build/tests/integration/lib/harness.js +70 -50
  23. package/build/tests/integration/lib/logger.d.ts +0 -1
  24. package/build/tests/integration/lib/logger.js +2 -4
  25. package/build/tests/integration/lib/tools.d.ts +6 -1
  26. package/build/tests/integration/lib/tools.js +32 -18
  27. package/build/tests/packageFiles/index.js +93 -77
  28. package/build/tests/unit/harness/createMocks.d.ts +3 -3
  29. package/build/tests/unit/harness/createMocks.js +1 -3
  30. package/build/tests/unit/index.js +6 -6
  31. package/build/tests/unit/mocks/mockAdapter.d.ts +3 -4
  32. package/build/tests/unit/mocks/mockAdapter.js +198 -164
  33. package/build/tests/unit/mocks/mockAdapterCore.d.ts +4 -10
  34. package/build/tests/unit/mocks/mockAdapterCore.js +24 -16
  35. package/build/tests/unit/mocks/mockDatabase.d.ts +13 -14
  36. package/build/tests/unit/mocks/mockDatabase.js +41 -45
  37. package/build/tests/unit/mocks/mockLogger.d.ts +1 -2
  38. package/build/tests/unit/mocks/mockLogger.js +2 -3
  39. package/build/tests/unit/mocks/tools.d.ts +2 -3
  40. package/build/tests/unit/mocks/tools.js +17 -15
  41. package/package.json +28 -32
@@ -1,4 +1,4 @@
1
- import type { DBConnection } from "./dbConnection";
1
+ import type { DBConnection } from './dbConnection';
2
2
  export declare class AdapterSetup {
3
3
  private adapterDir;
4
4
  private testDir;
@@ -15,20 +15,30 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.AdapterSetup = void 0;
30
- /* eslint-disable @typescript-eslint/no-empty-function */
31
40
  // Add debug logging for tests
41
+ // @ts-expect-error no types
32
42
  const objects_1 = require("alcalzone-shared/objects");
33
43
  const debug_1 = __importDefault(require("debug"));
34
44
  const fs_extra_1 = require("fs-extra");
@@ -36,12 +46,12 @@ const path = __importStar(require("path"));
36
46
  const adapterTools_1 = require("../../../lib/adapterTools");
37
47
  const executeCommand_1 = require("../../../lib/executeCommand");
38
48
  const tools_1 = require("./tools");
39
- const debug = (0, debug_1.default)("testing:integration:AdapterSetup");
49
+ const debug = (0, debug_1.default)('testing:integration:AdapterSetup');
40
50
  class AdapterSetup {
41
51
  constructor(adapterDir, testDir) {
42
52
  this.adapterDir = adapterDir;
43
53
  this.testDir = testDir;
44
- debug("Creating AdapterSetup...");
54
+ debug('Creating AdapterSetup...');
45
55
  this.adapterName = (0, adapterTools_1.getAdapterName)(this.adapterDir);
46
56
  this.adapterFullName = (0, adapterTools_1.getAdapterFullName)(this.adapterDir);
47
57
  this.appName = (0, adapterTools_1.getAppName)(this.adapterDir);
@@ -62,82 +72,85 @@ class AdapterSetup {
62
72
  }
63
73
  /** Copies all adapter files (except a few) to the test directory */
64
74
  async installAdapterInTestDir() {
65
- debug("Copying adapter files to test directory...");
75
+ debug('Copying adapter files to test directory...');
66
76
  // We install the adapter almost like it would be installed in the real world
67
77
  // Therefore pack it into a tarball and put it in the test dir for installation
68
- const packResult = await (0, executeCommand_1.executeCommand)("npm", ["pack", "--loglevel", "silent"], {
69
- stdout: "pipe",
78
+ const packResult = await (0, executeCommand_1.executeCommand)('npm', ['pack', '--loglevel', 'silent'], {
79
+ stdout: 'pipe',
70
80
  });
71
- if (packResult.exitCode !== 0 || typeof packResult.stdout !== "string")
81
+ if (packResult.exitCode !== 0 || typeof packResult.stdout !== 'string') {
72
82
  throw new Error(`Packing the adapter tarball failed!`);
83
+ }
73
84
  // The last non-empty line of `npm pack`s STDOUT contains the tarball path
74
85
  const stdoutLines = packResult.stdout.trim().split(/[\r\n]+/);
75
86
  const tarballName = stdoutLines[stdoutLines.length - 1].trim();
76
87
  const tarballPath = path.resolve(this.adapterDir, tarballName);
77
88
  await (0, fs_extra_1.copy)(tarballPath, path.resolve(this.testDir, tarballName));
78
89
  await (0, fs_extra_1.unlink)(tarballPath);
90
+ // Let npm remove the adapter in the package-lock.json file(s),
91
+ // so that the installation in the following step
92
+ // won't grab the cached files.
93
+ // See https://github.com/ioBroker/testing/issues/612
94
+ debug('Removing the adapter from package-lock.json');
95
+ await (0, executeCommand_1.executeCommand)('npm', ['uninstall', this.adapterFullName, '--package-lock-only', '--omit=dev'], {
96
+ cwd: this.testDir,
97
+ });
79
98
  // Complete the package.json, so npm can do it's magic
80
- debug("Saving the adapter in package.json");
81
- const packageJsonPath = path.join(this.testDir, "package.json");
99
+ debug('Saving the adapter in package.json');
100
+ const packageJsonPath = path.join(this.testDir, 'package.json');
82
101
  const packageJson = await (0, fs_extra_1.readJSON)(packageJsonPath);
83
102
  packageJson.dependencies[this.adapterFullName] = `file:./${tarballName}`;
84
103
  for (const [dep, version] of (0, objects_1.entries)((0, adapterTools_1.getAdapterDependencies)(this.adapterDir))) {
85
- // Don't overwrite the js-controller github dependency with a probably lower one
86
- if (dep === "js-controller")
104
+ // Don't overwrite the js-controller GitHub dependency with a probably lower one
105
+ if (dep === 'js-controller') {
87
106
  continue;
107
+ }
88
108
  packageJson.dependencies[`${this.appName}.${dep}`] = version;
89
109
  }
90
110
  await (0, fs_extra_1.writeJSON)(packageJsonPath, packageJson, { spaces: 2 });
91
- debug("Deleting old remains of this adapter");
92
- if (await (0, fs_extra_1.pathExists)(this.testAdapterDir))
111
+ debug('Deleting old remains of this adapter');
112
+ if (await (0, fs_extra_1.pathExists)(this.testAdapterDir)) {
93
113
  await (0, fs_extra_1.remove)(this.testAdapterDir);
94
- debug("Installing adapter");
114
+ }
115
+ debug('Installing adapter');
95
116
  // Defer to npm to install the controller (if it wasn't already)
96
- await (0, executeCommand_1.executeCommand)("npm", ["i", "--production"], {
117
+ await (0, executeCommand_1.executeCommand)('npm', ['i', '--omit=dev'], {
97
118
  cwd: this.testDir,
98
119
  });
99
- debug(" => done!");
120
+ debug(' => done!');
100
121
  }
101
122
  /**
102
123
  * Adds an instance for an already installed adapter in the test directory
103
124
  */
104
125
  async addAdapterInstance() {
105
- debug("Adding adapter instance...");
126
+ debug('Adding adapter instance...');
106
127
  // execute iobroker add <adapter> -- This also installs missing dependencies
107
- const addResult = await (0, executeCommand_1.executeCommand)("node", [
108
- `${this.appName}.js`,
109
- "add",
110
- this.adapterName,
111
- "--enabled",
112
- "false",
113
- ], {
128
+ const addResult = await (0, executeCommand_1.executeCommand)('node', [`${this.appName}.js`, 'add', this.adapterName, '--enabled', 'false'], {
114
129
  cwd: this.testControllerDir,
115
- stdout: "ignore",
130
+ stdout: 'ignore',
116
131
  });
117
- if (addResult.exitCode !== 0)
132
+ if (addResult.exitCode !== 0) {
118
133
  throw new Error(`Adding the adapter instance failed!`);
119
- debug(" => done!");
134
+ }
135
+ debug(' => done!');
120
136
  }
121
137
  async deleteOldInstances(dbConnection) {
122
- debug("Removing old adapter instances...");
123
- const allKeys = new Set([
124
- ...(await dbConnection.getObjectIDs()),
125
- ...(await dbConnection.getStateIDs()),
126
- ]);
138
+ debug('Removing old adapter instances...');
139
+ const allKeys = new Set([...(await dbConnection.getObjectIDs()), ...(await dbConnection.getStateIDs())]);
127
140
  const instanceRegex = new RegExp(`^system\\.adapter\\.${this.adapterName}\\.\\d+`);
128
- const instanceObjsRegex = new RegExp(`^${this.adapterName}\\.\\d+\.`);
141
+ const instanceObjsRegex = new RegExp(`^${this.adapterName}\\.\\d+\\.`);
129
142
  const belongsToAdapter = (id) => {
130
143
  return (instanceRegex.test(id) ||
131
144
  instanceObjsRegex.test(id) ||
132
145
  id === this.adapterName ||
133
146
  id === `${this.adapterName}.admin`);
134
147
  };
135
- const idsToDelete = [...allKeys].filter((id) => belongsToAdapter(id));
148
+ const idsToDelete = [...allKeys].filter(id => belongsToAdapter(id));
136
149
  for (const id of idsToDelete) {
137
150
  await dbConnection.delObject(id).catch(() => { });
138
151
  await dbConnection.delState(id).catch(() => { });
139
152
  }
140
- debug(" => done!");
153
+ debug(' => done!');
141
154
  }
142
155
  }
143
156
  exports.AdapterSetup = AdapterSetup;
@@ -1,4 +1,4 @@
1
- import type { DBConnection } from "./dbConnection";
1
+ import type { DBConnection } from './dbConnection';
2
2
  export declare class ControllerSetup {
3
3
  private adapterDir;
4
4
  private testDir;
@@ -11,8 +11,6 @@ export declare class ControllerSetup {
11
11
  prepareTestDir(controllerVersion?: string): Promise<void>;
12
12
  /**
13
13
  * Tests if JS-Controller is already installed
14
- * @param appName The branded name of "iobroker"
15
- * @param testDir The directory the integration tests are executed in
16
14
  */
17
15
  isJsControllerInstalled(): Promise<boolean>;
18
16
  /**
@@ -25,25 +23,18 @@ export declare class ControllerSetup {
25
23
  setupJsController(): Promise<void>;
26
24
  /**
27
25
  * Changes the objects and states db to use alternative ports
28
- * @param appName The branded name of "iobroker"
29
- * @param testDir The directory the integration tests are executed in
30
26
  */
31
27
  setupSystemConfig(dbConnection: DBConnection): void;
32
28
  /**
33
29
  * Clears the log dir for integration tests (and creates it if it doesn't exist)
34
- * @param appName The branded name of "iobroker"
35
- * @param testDir The directory the integration tests are executed in
36
30
  */
37
31
  clearLogDir(): Promise<void>;
38
32
  /**
39
33
  * Clears the sqlite DB dir for integration tests (and creates it if it doesn't exist)
40
- * @param appName The branded name of "iobroker"
41
- * @param testDir The directory the integration tests are executed in
42
34
  */
43
35
  clearDBDir(): Promise<void>;
44
36
  /**
45
37
  * Disables all admin instances in the objects DB
46
- * @param objects The contents of objects.json
47
38
  */
48
39
  disableAdminInstances(dbConnection: DBConnection): Promise<void>;
49
40
  }
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -35,12 +45,12 @@ const path = __importStar(require("path"));
35
45
  const adapterTools_1 = require("../../../lib/adapterTools");
36
46
  const executeCommand_1 = require("../../../lib/executeCommand");
37
47
  const tools_1 = require("./tools");
38
- const debug = (0, debug_1.default)("testing:integration:ControllerSetup");
48
+ const debug = (0, debug_1.default)('testing:integration:ControllerSetup');
39
49
  class ControllerSetup {
40
50
  constructor(adapterDir, testDir) {
41
51
  this.adapterDir = adapterDir;
42
52
  this.testDir = testDir;
43
- debug("Creating ControllerSetup...");
53
+ debug('Creating ControllerSetup...');
44
54
  this.adapterName = (0, adapterTools_1.getAdapterName)(this.adapterDir);
45
55
  this.appName = (0, adapterTools_1.getAppName)(this.adapterDir);
46
56
  this.testAdapterDir = (0, tools_1.getTestAdapterDir)(this.adapterDir, this.testDir);
@@ -53,60 +63,59 @@ class ControllerSetup {
53
63
  debug(` appName: ${this.appName}`);
54
64
  debug(` adapterName: ${this.adapterName}`);
55
65
  }
56
- async prepareTestDir(controllerVersion = "dev") {
66
+ async prepareTestDir(controllerVersion = 'dev') {
57
67
  debug(`Preparing the test directory. JS-Controller version: "${controllerVersion}"...`);
58
68
  // Make sure the test dir exists
59
69
  await (0, fs_extra_1.ensureDir)(this.testDir);
60
70
  // Write the package.json
61
71
  const packageJson = {
62
72
  name: path.basename(this.testDir),
63
- version: "1.0.0",
64
- main: "index.js",
73
+ version: '1.0.0',
74
+ main: 'index.js',
65
75
  scripts: {
66
76
  test: 'echo "Error: no test specified" && exit 1',
67
77
  },
68
78
  keywords: [],
69
- author: "",
70
- license: "ISC",
79
+ author: '',
80
+ license: 'ISC',
71
81
  dependencies: {
72
82
  [`${this.appName}.js-controller`]: controllerVersion,
73
83
  },
74
- description: "",
84
+ description: '',
75
85
  };
76
- await (0, fs_extra_1.writeJSON)(path.join(this.testDir, "package.json"), packageJson, {
86
+ await (0, fs_extra_1.writeJSON)(path.join(this.testDir, 'package.json'), packageJson, {
77
87
  spaces: 2,
78
88
  });
79
89
  // Delete a possible package-lock.json as it can mess with future installations
80
- const pckLockPath = path.join(this.testDir, "package-lock.json");
81
- if (await (0, fs_extra_1.pathExists)(pckLockPath))
90
+ const pckLockPath = path.join(this.testDir, 'package-lock.json');
91
+ if (await (0, fs_extra_1.pathExists)(pckLockPath)) {
82
92
  await (0, fs_extra_1.unlink)(pckLockPath);
93
+ }
83
94
  // Set the engineStrict flag on new Node.js versions to be in line with newer ioBroker installations
84
- const nodeMajorVersion = parseInt(process.versions.node.split(".")[0], 10);
95
+ const nodeMajorVersion = parseInt(process.versions.node.split('.')[0], 10);
85
96
  if (nodeMajorVersion >= 10) {
86
- await (0, fs_extra_1.writeFile)(path.join(this.testDir, ".npmrc"), "engine-strict=true", "utf8");
97
+ await (0, fs_extra_1.writeFile)(path.join(this.testDir, '.npmrc'), 'engine-strict=true', 'utf8');
87
98
  }
88
99
  // Remember if JS-Controller is installed already. If so, we need to call `setup first` afterwards
89
100
  const wasJsControllerInstalled = await this.isJsControllerInstalled();
90
101
  // Defer to npm to install the controller (if it wasn't already)
91
- debug("(Re-)installing JS Controller...");
92
- await (0, executeCommand_1.executeCommand)("npm", ["i", "--production"], {
102
+ debug('(Re-)installing JS Controller...');
103
+ await (0, executeCommand_1.executeCommand)('npm', ['i', '--omit=dev'], {
93
104
  cwd: this.testDir,
94
105
  });
95
106
  // Prepare/clean the databases and config
96
- if (wasJsControllerInstalled)
107
+ if (wasJsControllerInstalled) {
97
108
  await this.setupJsController();
98
- debug(" => done!");
109
+ }
110
+ debug(' => done!');
99
111
  }
100
112
  /**
101
113
  * Tests if JS-Controller is already installed
102
- * @param appName The branded name of "iobroker"
103
- * @param testDir The directory the integration tests are executed in
104
114
  */
105
115
  async isJsControllerInstalled() {
106
- debug("Testing if JS-Controller is installed...");
116
+ debug('Testing if JS-Controller is installed...');
107
117
  // We expect js-controller to be installed if the dir in <testDir>/node_modules and the data directory exist
108
- const isInstalled = (await (0, fs_extra_1.pathExists)(this.testControllerDir)) &&
109
- (await (0, fs_extra_1.pathExists)(this.testDataDir));
118
+ const isInstalled = (await (0, fs_extra_1.pathExists)(this.testControllerDir)) && (await (0, fs_extra_1.pathExists)(this.testDataDir));
110
119
  debug(` => ${isInstalled}`);
111
120
  return isInstalled;
112
121
  }
@@ -114,8 +123,8 @@ class ControllerSetup {
114
123
  * Tests if an instance of JS-Controller is already running by attempting to connect to the Objects DB
115
124
  */
116
125
  isJsControllerRunning() {
117
- debug("Testing if JS-Controller is running...");
118
- return new Promise((resolve) => {
126
+ debug('Testing if JS-Controller is running...');
127
+ return new Promise(resolve => {
119
128
  const client = new net_1.Socket();
120
129
  const timeout = setTimeout(() => {
121
130
  // Assume the connection failed after 1 s
@@ -127,16 +136,16 @@ class ControllerSetup {
127
136
  client
128
137
  .connect({
129
138
  port: 9000,
130
- host: "127.0.0.1",
139
+ host: '127.0.0.1',
131
140
  })
132
- .on("connect", () => {
141
+ .on('connect', () => {
133
142
  // The connection succeeded
134
143
  client.destroy();
135
144
  debug(` => true`);
136
145
  clearTimeout(timeout);
137
146
  resolve(true);
138
147
  })
139
- .on("error", () => {
148
+ .on('error', () => {
140
149
  client.destroy();
141
150
  debug(` => false`);
142
151
  clearTimeout(timeout);
@@ -168,24 +177,23 @@ class ControllerSetup {
168
177
  * Sets up an existing JS-Controller instance for testing by executing "iobroker setup first"
169
178
  */
170
179
  async setupJsController() {
171
- debug("Initializing JS-Controller installation...");
180
+ debug('Initializing JS-Controller installation...');
172
181
  // Stop the controller before calling setup first
173
- await (0, executeCommand_1.executeCommand)("node", [`${this.appName}.js`, "stop"], {
182
+ await (0, executeCommand_1.executeCommand)('node', [`${this.appName}.js`, 'stop'], {
174
183
  cwd: this.testControllerDir,
175
- stdout: "ignore",
184
+ stdout: 'ignore',
176
185
  });
177
- const setupResult = await (0, executeCommand_1.executeCommand)("node", [`${this.appName}.js`, "setup", "first", "--console"], {
186
+ const setupResult = await (0, executeCommand_1.executeCommand)('node', [`${this.appName}.js`, 'setup', 'first', '--console'], {
178
187
  cwd: this.testControllerDir,
179
- stdout: "ignore",
188
+ stdout: 'ignore',
180
189
  });
181
- if (setupResult.exitCode !== 0)
190
+ if (setupResult.exitCode !== 0) {
182
191
  throw new Error(`${this.appName} setup first failed!`);
183
- debug(" => done!");
192
+ }
193
+ debug(' => done!');
184
194
  }
185
195
  /**
186
196
  * Changes the objects and states db to use alternative ports
187
- * @param appName The branded name of "iobroker"
188
- * @param testDir The directory the integration tests are executed in
189
197
  */
190
198
  setupSystemConfig(dbConnection) {
191
199
  debug(`Moving databases to different ports...`);
@@ -193,35 +201,30 @@ class ControllerSetup {
193
201
  systemConfig.objects.port = 19001;
194
202
  systemConfig.states.port = 19000;
195
203
  dbConnection.setSystemConfig(systemConfig);
196
- debug(" => done!");
204
+ debug(' => done!');
197
205
  }
198
206
  /**
199
207
  * Clears the log dir for integration tests (and creates it if it doesn't exist)
200
- * @param appName The branded name of "iobroker"
201
- * @param testDir The directory the integration tests are executed in
202
208
  */
203
209
  clearLogDir() {
204
- debug("Cleaning log directory...");
210
+ debug('Cleaning log directory...');
205
211
  return (0, fs_extra_1.emptyDir)((0, tools_1.getTestLogDir)(this.appName, this.testDir));
206
212
  }
207
213
  /**
208
214
  * Clears the sqlite DB dir for integration tests (and creates it if it doesn't exist)
209
- * @param appName The branded name of "iobroker"
210
- * @param testDir The directory the integration tests are executed in
211
215
  */
212
216
  clearDBDir() {
213
- debug("Cleaning SQLite directory...");
217
+ debug('Cleaning SQLite directory...');
214
218
  return (0, fs_extra_1.emptyDir)((0, tools_1.getTestDBDir)(this.appName, this.testDir));
215
219
  }
216
220
  /**
217
221
  * Disables all admin instances in the objects DB
218
- * @param objects The contents of objects.json
219
222
  */
220
223
  async disableAdminInstances(dbConnection) {
221
- debug("Disabling admin instances...");
222
- const instanceObjects = await dbConnection.getObjectViewAsync("system", "instance", {
223
- startkey: "system.adapter.admin.",
224
- endkey: "system.adapter.admin.\u9999",
224
+ debug('Disabling admin instances...');
225
+ const instanceObjects = await dbConnection.getObjectViewAsync('system', 'instance', {
226
+ startkey: 'system.adapter.admin.',
227
+ endkey: 'system.adapter.admin.\u9999',
225
228
  });
226
229
  for (const { id, value: obj } of instanceObjects.rows) {
227
230
  if (obj && obj.common) {
@@ -229,7 +232,7 @@ class ControllerSetup {
229
232
  await dbConnection.setObject(id, obj);
230
233
  }
231
234
  }
232
- debug(" => done!");
235
+ debug(' => done!');
233
236
  }
234
237
  }
235
238
  exports.ControllerSetup = ControllerSetup;
@@ -1,13 +1,9 @@
1
- /// <reference types="iobroker" />
2
- /// <reference types="iobroker" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- import EventEmitter from "events";
1
+ import EventEmitter from 'events';
6
2
  export type ObjectsDB = Record<string, ioBroker.Object>;
7
3
  export type StatesDB = Record<string, ioBroker.State>;
8
4
  export interface DBConnection {
9
- on(event: "objectChange", handler: ioBroker.ObjectChangeHandler): this;
10
- on(event: "stateChange", handler: ioBroker.StateChangeHandler): this;
5
+ on(event: 'objectChange', handler: ioBroker.ObjectChangeHandler): this;
6
+ on(event: 'stateChange', handler: ioBroker.StateChangeHandler): this;
11
7
  }
12
8
  /** The DB connection capsules access to the states and objects DB */
13
9
  export declare class DBConnection extends EventEmitter {
@@ -29,9 +25,9 @@ export declare class DBConnection extends EventEmitter {
29
25
  private _statesClient;
30
26
  /** The underlying states client instance that can be used to access the states DB */
31
27
  get statesClient(): any;
32
- get objectsType(): "file" | "jsonl";
28
+ get objectsType(): 'file' | 'jsonl';
33
29
  get objectsPath(): string;
34
- get statesType(): "file" | "jsonl";
30
+ get statesType(): 'file' | 'jsonl';
35
31
  get statesPath(): string;
36
32
  getSystemConfig(): any;
37
33
  backup(): Promise<{
@@ -48,15 +44,15 @@ export declare class DBConnection extends EventEmitter {
48
44
  private createObjectsDB;
49
45
  /** Creates the states DB and sets up listeners for it */
50
46
  private createStatesDB;
51
- readonly getObject: ioBroker.Adapter["getForeignObjectAsync"];
52
- readonly setObject: ioBroker.Adapter["setForeignObjectAsync"];
53
- readonly delObject: ioBroker.Adapter["delForeignObjectAsync"];
54
- readonly getState: ioBroker.Adapter["getForeignStateAsync"];
55
- readonly setState: ioBroker.Adapter["setForeignStateAsync"];
56
- readonly delState: ioBroker.Adapter["delForeignStateAsync"];
47
+ readonly getObject: ioBroker.Adapter['getForeignObjectAsync'];
48
+ readonly setObject: ioBroker.Adapter['setForeignObjectAsync'];
49
+ readonly delObject: ioBroker.Adapter['delForeignObjectAsync'];
50
+ readonly getState: ioBroker.Adapter['getForeignStateAsync'];
51
+ readonly setState: ioBroker.Adapter['setForeignStateAsync'];
52
+ readonly delState: ioBroker.Adapter['delForeignStateAsync'];
57
53
  subscribeMessage(id: string): void;
58
54
  pushMessage(instanceId: string, msg: any, callback: (err: Error | null, id: any) => void): void;
59
- readonly getObjectViewAsync: ioBroker.Adapter["getObjectViewAsync"];
55
+ readonly getObjectViewAsync: ioBroker.Adapter['getObjectViewAsync'];
60
56
  getStateIDs(pattern?: string): Promise<string[]>;
61
57
  getObjectIDs(pattern?: string): Promise<string[]>;
62
58
  }