Config element mocking is broken in BT 2.34.0
Description
@Michaelpalacce it seems you actually broke more than you fixed. Following test (demo.test.ts) works as expected in 2.33.0, but throws in 2.34.0:
Steps to Reproduce
function getConfigurationElementByPath (path: string, name: string): ConfigurationElement {
const configurationElementCategory = Server.getConfigurationElementCategoryWithPath(path)
const configurationElements = configurationElementCategory.allConfigurationElements
const configurationElement = configurationElements.filter(function (configurationElement) {
return configurationElement.name === name
})
if (configurationElement.length !== 1) {
throw new Error('too many or zero matches')
}
return configurationElement[0]
}
function demo (): string {
const environment = getConfigurationElementByPath('web-root', 'Environment')
return `demo${environment.getAttributeWithKey('demo').value as string}`
}
describe('demo test', () => {
beforeEach(() => {
const envCfg = Server.createConfigurationElement('web-root', 'Environment')
envCfg.setAttributeWithKey('demo', 'Mock', 'string')
})
afterEach(() => {
Server.removeConfigurationElementCategory(Server.getConfigurationElementCategoryWithPath('web-root')) // cleanup all cfgElements
})
it('x', () => {
expect(demo()).toBe('demoMock')
})
})
Expected behavior:
expected behaviour is environment.getAttributeWithKey('demo').value to equal 'Mock', but environment.getAttributeWithKey() returns null, even if the attribute exists.
Reproduces how often:
100%
Environment
Client
- Build Tools for VMware Aria Version: 2.34.0
- Visual Studio Code Version: n/a
- OS Version: Windows & MacOs
Server
- vRealize Automation Version: n/a
- vRealize Orchestrator Version: n/a
- vRealize Operations Version: n/a
- vRealize Log Insight Version: n/a
Failure Logs
Related issues and PRs
#110
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
@Michaelpalacce just to check, this requirement is still valid, right?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
@Michaelpalacce reminder to check if this is still valid
Hi,
I think it is.
Hi Guys,
sorry for responding so slowly... I just did a few tests and can confirm that this is still an issue with 2.37. Basically, cfg el mocking is broken in all 2.34 and up.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Not stale, there is a PR open with discussion: https://github.com/vmware/build-tools-for-vmware-aria/pull/265
I think my PR has been merged, meaning that this issue is now resolved.