@iobroker/testing 5.0.0 → 5.0.3

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 (37) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/build/index.d.ts +1 -1
  4. package/build/lib/adapterTools.d.ts +7 -1
  5. package/build/lib/adapterTools.js +36 -21
  6. package/build/lib/executeCommand.d.ts +3 -2
  7. package/build/lib/executeCommand.js +30 -29
  8. package/build/lib/str2regex.js +4 -4
  9. package/build/tests/index.d.ts +9 -9
  10. package/build/tests/integration/index.d.ts +1 -1
  11. package/build/tests/integration/index.js +44 -39
  12. package/build/tests/integration/lib/adapterSetup.d.ts +1 -1
  13. package/build/tests/integration/lib/adapterSetup.js +50 -52
  14. package/build/tests/integration/lib/controllerSetup.d.ts +1 -10
  15. package/build/tests/integration/lib/controllerSetup.js +59 -56
  16. package/build/tests/integration/lib/dbConnection.d.ts +12 -12
  17. package/build/tests/integration/lib/dbConnection.js +71 -69
  18. package/build/tests/integration/lib/harness.d.ts +9 -7
  19. package/build/tests/integration/lib/harness.js +68 -49
  20. package/build/tests/integration/lib/logger.js +1 -1
  21. package/build/tests/integration/lib/tools.d.ts +6 -1
  22. package/build/tests/integration/lib/tools.js +27 -12
  23. package/build/tests/packageFiles/index.js +92 -90
  24. package/build/tests/unit/harness/createMocks.d.ts +3 -2
  25. package/build/tests/unit/harness/createMocks.js +0 -1
  26. package/build/tests/unit/index.js +5 -4
  27. package/build/tests/unit/mocks/mockAdapter.d.ts +3 -3
  28. package/build/tests/unit/mocks/mockAdapter.js +195 -162
  29. package/build/tests/unit/mocks/mockAdapterCore.d.ts +4 -9
  30. package/build/tests/unit/mocks/mockAdapterCore.js +23 -14
  31. package/build/tests/unit/mocks/mockDatabase.d.ts +13 -12
  32. package/build/tests/unit/mocks/mockDatabase.js +40 -45
  33. package/build/tests/unit/mocks/mockLogger.d.ts +1 -1
  34. package/build/tests/unit/mocks/mockLogger.js +1 -1
  35. package/build/tests/unit/mocks/tools.d.ts +2 -2
  36. package/build/tests/unit/mocks/tools.js +14 -11
  37. package/package.json +15 -22
@@ -15,32 +15,41 @@ 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
40
  // Add debug logging for tests
31
- const objects_1 = require("alcalzone-shared/objects");
32
41
  const debug_1 = __importDefault(require("debug"));
33
42
  const fs_extra_1 = require("fs-extra");
34
43
  const path = __importStar(require("path"));
35
44
  const adapterTools_1 = require("../../../lib/adapterTools");
36
45
  const executeCommand_1 = require("../../../lib/executeCommand");
37
46
  const tools_1 = require("./tools");
38
- const debug = (0, debug_1.default)("testing:integration:AdapterSetup");
47
+ const debug = (0, debug_1.default)('testing:integration:AdapterSetup');
39
48
  class AdapterSetup {
40
49
  constructor(adapterDir, testDir) {
41
50
  this.adapterDir = adapterDir;
42
51
  this.testDir = testDir;
43
- debug("Creating AdapterSetup...");
52
+ debug('Creating AdapterSetup...');
44
53
  this.adapterName = (0, adapterTools_1.getAdapterName)(this.adapterDir);
45
54
  this.adapterFullName = (0, adapterTools_1.getAdapterFullName)(this.adapterDir);
46
55
  this.appName = (0, adapterTools_1.getAppName)(this.adapterDir);
@@ -61,14 +70,15 @@ class AdapterSetup {
61
70
  }
62
71
  /** Copies all adapter files (except a few) to the test directory */
63
72
  async installAdapterInTestDir() {
64
- debug("Copying adapter files to test directory...");
73
+ debug('Copying adapter files to test directory...');
65
74
  // We install the adapter almost like it would be installed in the real world
66
75
  // Therefore pack it into a tarball and put it in the test dir for installation
67
- const packResult = await (0, executeCommand_1.executeCommand)("npm", ["pack", "--loglevel", "silent"], {
68
- stdout: "pipe",
76
+ const packResult = await (0, executeCommand_1.executeCommand)('npm', ['pack', '--loglevel', 'silent'], {
77
+ stdout: 'pipe',
69
78
  });
70
- if (packResult.exitCode !== 0 || typeof packResult.stdout !== "string")
79
+ if (packResult.exitCode !== 0 || typeof packResult.stdout !== 'string') {
71
80
  throw new Error(`Packing the adapter tarball failed!`);
81
+ }
72
82
  // The last non-empty line of `npm pack`s STDOUT contains the tarball path
73
83
  const stdoutLines = packResult.stdout.trim().split(/[\r\n]+/);
74
84
  const tarballName = stdoutLines[stdoutLines.length - 1].trim();
@@ -79,78 +89,66 @@ class AdapterSetup {
79
89
  // so that the installation in the following step
80
90
  // won't grab the cached files.
81
91
  // See https://github.com/ioBroker/testing/issues/612
82
- debug("Removing the adapter from package-lock.json");
83
- await (0, executeCommand_1.executeCommand)("npm", [
84
- "uninstall",
85
- this.adapterFullName,
86
- "--package-lock-only",
87
- "--omit=dev",
88
- ], {
92
+ debug('Removing the adapter from package-lock.json');
93
+ await (0, executeCommand_1.executeCommand)('npm', ['uninstall', this.adapterFullName, '--package-lock-only', '--omit=dev'], {
89
94
  cwd: this.testDir,
90
95
  });
91
96
  // Complete the package.json, so npm can do it's magic
92
- debug("Saving the adapter in package.json");
93
- const packageJsonPath = path.join(this.testDir, "package.json");
97
+ debug('Saving the adapter in package.json');
98
+ const packageJsonPath = path.join(this.testDir, 'package.json');
94
99
  const packageJson = await (0, fs_extra_1.readJSON)(packageJsonPath);
95
- packageJson.dependencies[this.adapterFullName] =
96
- `file:./${tarballName}`;
97
- for (const [dep, version] of (0, objects_1.entries)((0, adapterTools_1.getAdapterDependencies)(this.adapterDir))) {
98
- // Don't overwrite the js-controller github dependency with a probably lower one
99
- if (dep === "js-controller")
100
+ packageJson.dependencies[this.adapterFullName] = `file:./${tarballName}`;
101
+ for (const [dep, version] of Object.entries((0, adapterTools_1.getAdapterDependencies)(this.adapterDir))) {
102
+ // Don't overwrite the js-controller GitHub dependency with a probably lower one
103
+ if (dep === 'js-controller') {
100
104
  continue;
105
+ }
101
106
  packageJson.dependencies[`${this.appName}.${dep}`] = version;
102
107
  }
103
108
  await (0, fs_extra_1.writeJSON)(packageJsonPath, packageJson, { spaces: 2 });
104
- debug("Deleting old remains of this adapter");
105
- if (await (0, fs_extra_1.pathExists)(this.testAdapterDir))
109
+ debug('Deleting old remains of this adapter');
110
+ if (await (0, fs_extra_1.pathExists)(this.testAdapterDir)) {
106
111
  await (0, fs_extra_1.remove)(this.testAdapterDir);
107
- debug("Installing adapter");
112
+ }
113
+ debug('Installing adapter');
108
114
  // Defer to npm to install the controller (if it wasn't already)
109
- await (0, executeCommand_1.executeCommand)("npm", ["i", "--omit=dev"], {
115
+ await (0, executeCommand_1.executeCommand)('npm', ['i', '--omit=dev'], {
110
116
  cwd: this.testDir,
111
117
  });
112
- debug(" => done!");
118
+ debug(' => done!');
113
119
  }
114
120
  /**
115
121
  * Adds an instance for an already installed adapter in the test directory
116
122
  */
117
123
  async addAdapterInstance() {
118
- debug("Adding adapter instance...");
124
+ debug('Adding adapter instance...');
119
125
  // execute iobroker add <adapter> -- This also installs missing dependencies
120
- const addResult = await (0, executeCommand_1.executeCommand)("node", [
121
- `${this.appName}.js`,
122
- "add",
123
- this.adapterName,
124
- "--enabled",
125
- "false",
126
- ], {
126
+ const addResult = await (0, executeCommand_1.executeCommand)('node', [`${this.appName}.js`, 'add', this.adapterName, '--enabled', 'false'], {
127
127
  cwd: this.testControllerDir,
128
- stdout: "ignore",
128
+ stdout: 'ignore',
129
129
  });
130
- if (addResult.exitCode !== 0)
130
+ if (addResult.exitCode !== 0) {
131
131
  throw new Error(`Adding the adapter instance failed!`);
132
- debug(" => done!");
132
+ }
133
+ debug(' => done!');
133
134
  }
134
135
  async deleteOldInstances(dbConnection) {
135
- debug("Removing old adapter instances...");
136
- const allKeys = new Set([
137
- ...(await dbConnection.getObjectIDs()),
138
- ...(await dbConnection.getStateIDs()),
139
- ]);
136
+ debug('Removing old adapter instances...');
137
+ const allKeys = new Set([...(await dbConnection.getObjectIDs()), ...(await dbConnection.getStateIDs())]);
140
138
  const instanceRegex = new RegExp(`^system\\.adapter\\.${this.adapterName}\\.\\d+`);
141
- const instanceObjsRegex = new RegExp(`^${this.adapterName}\\.\\d+\.`);
139
+ const instanceObjsRegex = new RegExp(`^${this.adapterName}\\.\\d+\\.`);
142
140
  const belongsToAdapter = (id) => {
143
141
  return (instanceRegex.test(id) ||
144
142
  instanceObjsRegex.test(id) ||
145
143
  id === this.adapterName ||
146
144
  id === `${this.adapterName}.admin`);
147
145
  };
148
- const idsToDelete = [...allKeys].filter((id) => belongsToAdapter(id));
146
+ const idsToDelete = [...allKeys].filter(id => belongsToAdapter(id));
149
147
  for (const id of idsToDelete) {
150
148
  await dbConnection.delObject(id).catch(() => { });
151
149
  await dbConnection.delState(id).catch(() => { });
152
150
  }
153
- debug(" => done!");
151
+ debug(' => done!');
154
152
  }
155
153
  }
156
154
  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", "--omit=dev"], {
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,9 +1,9 @@
1
- import EventEmitter from "events";
1
+ import EventEmitter from 'events';
2
2
  export type ObjectsDB = Record<string, ioBroker.Object>;
3
3
  export type StatesDB = Record<string, ioBroker.State>;
4
4
  export interface DBConnection {
5
- on(event: "objectChange", handler: ioBroker.ObjectChangeHandler): this;
6
- on(event: "stateChange", handler: ioBroker.StateChangeHandler): this;
5
+ on(event: 'objectChange', handler: ioBroker.ObjectChangeHandler): this;
6
+ on(event: 'stateChange', handler: ioBroker.StateChangeHandler): this;
7
7
  }
8
8
  /** The DB connection capsules access to the states and objects DB */
9
9
  export declare class DBConnection extends EventEmitter {
@@ -25,9 +25,9 @@ export declare class DBConnection extends EventEmitter {
25
25
  private _statesClient;
26
26
  /** The underlying states client instance that can be used to access the states DB */
27
27
  get statesClient(): any;
28
- get objectsType(): "file" | "jsonl";
28
+ get objectsType(): 'file' | 'jsonl';
29
29
  get objectsPath(): string;
30
- get statesType(): "file" | "jsonl";
30
+ get statesType(): 'file' | 'jsonl';
31
31
  get statesPath(): string;
32
32
  getSystemConfig(): any;
33
33
  backup(): Promise<{
@@ -44,15 +44,15 @@ export declare class DBConnection extends EventEmitter {
44
44
  private createObjectsDB;
45
45
  /** Creates the states DB and sets up listeners for it */
46
46
  private createStatesDB;
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"];
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'];
53
53
  subscribeMessage(id: string): void;
54
54
  pushMessage(instanceId: string, msg: any, callback: (err: Error | null, id: any) => void): void;
55
- readonly getObjectViewAsync: ioBroker.Adapter["getObjectViewAsync"];
55
+ readonly getObjectViewAsync: ioBroker.Adapter['getObjectViewAsync'];
56
56
  getStateIDs(pattern?: string): Promise<string[]>;
57
57
  getObjectIDs(pattern?: string): Promise<string[]>;
58
58
  }