@squiz/dxp-cli-next 5.17.0-develop.4 → 5.17.0

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.
@@ -171,6 +171,15 @@ describe('datastoreSimulatorUpgrade', () => {
171
171
  case 14:
172
172
  expect(cmd).toStrictEqual('docker exec datastore-sim-6909fc2c cat /var/www/data/containerData.json');
173
173
  return Promise.resolve('{}');
174
+ case 15:
175
+ expect(cmd).toStrictEqual('docker exec datastore-sim-6909fc2c bash -c "rm -rf /var/www/data/storage; rm -rf /var/www/data/provision/**/oven"');
176
+ return Promise.resolve('');
177
+ case 16:
178
+ expect(cmd).toStrictEqual('docker image inspect squizdxp/datastore:latest --format \'{{ or (index .Config.Labels "squiz.datastore.version") (printf "Unknown") }}\'');
179
+ return Promise.resolve('4.0.1');
180
+ case 17:
181
+ expect(cmd).toStrictEqual('rm -rf /tmp/datastore-XXXXXXXXXX');
182
+ return Promise.resolve('');
174
183
  }
175
184
  return Promise.reject(false);
176
185
  });
@@ -163,3 +163,39 @@ describe('checkUpdateAvailable', () => {
163
163
  expect(promptSpy).toHaveBeenCalled();
164
164
  }));
165
165
  });
166
+ describe('writeSimulatorContainerData', () => {
167
+ const containerName = 'test-container';
168
+ const blueprintPath = '/path/to/blueprint.yaml';
169
+ const digest = 'sha256:abcdef1234567890';
170
+ const version = '1.0.0';
171
+ it('should write simulator container data correctly', () => __awaiter(void 0, void 0, void 0, function* () {
172
+ const expectedInstallCommandResponse = JSON.stringify([
173
+ {
174
+ URL: 'http://localhost:7001',
175
+ jwtURL: 'http://localhost:7001/jwt',
176
+ },
177
+ ]);
178
+ const execSpy = jest
179
+ .spyOn(utils, 'executeCommand')
180
+ .mockResolvedValue(expectedInstallCommandResponse);
181
+ const expectedResponse = {
182
+ url: 'http://localhost:7001',
183
+ jwtUrl: 'http://localhost:7001/jwt',
184
+ };
185
+ const response = yield utils.writeSimulatorContainerData(containerName, blueprintPath, digest, version);
186
+ expect(execSpy).toHaveBeenNthCalledWith(1, `docker exec -i ${containerName} install simulator:blueprint.yaml --output=json`);
187
+ const jsonObject = {
188
+ blueprint: blueprintPath,
189
+ container: containerName,
190
+ imageDigest: digest,
191
+ imageVersion: version,
192
+ jwt: 'http://localhost:7001/jwt',
193
+ url: 'http://localhost:7001',
194
+ };
195
+ const jsonString = JSON.stringify(jsonObject, null, 4).replace(/"/g, '\\"');
196
+ const expectedEchoCommand = `docker exec -i ${containerName} bash -c "echo '${jsonString}' > /var/www/data/containerData.json"`;
197
+ const actualEchoCommand = execSpy.mock.calls[1][0];
198
+ expect(actualEchoCommand).toBe(expectedEchoCommand);
199
+ expect(response).toStrictEqual(expectedResponse);
200
+ }));
201
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/dxp-cli-next",
3
- "version": "5.17.0-develop.4",
3
+ "version": "5.17.0",
4
4
  "repository": {
5
5
  "url": "https://gitlab.squiz.net/dxp/dxp-cli-next"
6
6
  },