Deleting the setting after each test execution.
MODIFY
test/api/AssetTest.ts
test/api/AssetTest.ts
@@ -33,6 +33,7 @@ class TestData {
public createdAssets: Asset[] = [];
public ioThinkAssetConnectorID: string;
public pending: boolean;
+ public settings: SettingDB;
}
const testData: TestData = new TestData();
@@ -75,6 +76,12 @@ const createOrUpdateSettings = async (settingID: string, url: string, user: stri
return settingUpdated;
};
+const deleteAssetSettings = async (setting: SettingDB) => {
+ if (setting) {
+ await testData.centralUserService.settingApi.delete(setting);
+ }
+};
+
describe('Asset', function() {
this.timeout(1000000); // Will automatically stop the unit test after that period of time
@@ -400,8 +407,8 @@ describe('Asset', function() {
const url = config.get('assetConnectors.ioThink.url');
const user = config.get('assetConnectors.ioThink.user');
const password = config.get('assetConnectors.ioThink.password');
- const settingUpdated = await createOrUpdateSettings(settingID, url, user, password);
- expect(settingUpdated.content.asset.connections[0].id).to.be.eq(settingID);
+ testData.settings = await createOrUpdateSettings(settingID, url, user, password);
+ expect(testData.settings.content.asset.connections[0].id).to.be.eq(settingID);
testData.ioThinkAssetConnectorID = settingID;
});
@@ -434,11 +441,15 @@ describe('Asset', function() {
const url = config.get('assetConnectors.ioThink.url');
const user = 'WrongUser';
const password = 'WrongPassword';
- const settingUpdated = await createOrUpdateSettings(settingID, url, user, password);
- expect(settingUpdated.content.asset.connections[0].id).to.be.eq(settingID);
+ testData.settings = await createOrUpdateSettings(settingID, url, user, password);
+ expect(testData.settings.content.asset.connections[0].id).to.be.eq(settingID);
const response = await testData.centralUserService.assetApi.retrieveLatestConsumption(testData.newAsset.id);
expect(response.status).to.be.eq(StatusCodes.INTERNAL_SERVER_ERROR);
});
+
+ after(async () => {
+ await deleteAssetSettings(testData.settings);
+ });
});
});
});

Deleting the setting after each test execution.