MCPcopy Index your code
hub / github.com/cloudgraphdev/cli / runInitCommandTester

Function runInitCommandTester

test/helpers/index.ts:210–249  ·  view source on GitHub ↗
(
  spyFn: jest.SpyInstance,
  mock: MockRunInitCmdPromptExpectation,
  removeConfig = false,
  debug = false
)

Source from the content-addressed store, hash-verified

208}
209
210export const runInitCommandTester = async (
211 spyFn: jest.SpyInstance,
212 mock: MockRunInitCmdPromptExpectation,
213 removeConfig = false,
214 debug = false
215): Promise<void> => {
216 debug && logger.debug('******')
217 debug && logger.debug('Test InitCommand.run()')
218 debug && logger.debug(`argvList: ${JSON.stringify(mock.argvList)}`)
219 const InitCommand = await getInitCommand(mock.argvList, 'aws')
220 if (removeConfig) {
221 removeConfigFile(debug)
222 // remove all overwrite prompt mocks
223 mock.promptExpectation = mock.promptExpectation.filter(
224 i => !('overwrite' in i)
225 )
226 }
227 debug && logger.debug(`mock: ${JSON.stringify(mock)}`)
228 const originalConfigFile = !removeConfig ? getConfigFile(debug) : {}
229 mock.promptExpectation.forEach(expectation =>
230 spyFn.mockResolvedValueOnce(expectation)
231 )
232 await InitCommand.run()
233 const newConfigFile = getConfigFile(debug)
234 if (
235 !mock.overwriteFlags.overwriteProviderConfig &&
236 !mock.overwriteFlags.overwriteCloudGraphConfig
237 ) {
238 // Test config is unchanged
239 expect(newConfigFile).toMatchObject(originalConfigFile)
240 }
241 if (
242 !mock.overwriteFlags.overwriteProviderConfig &&
243 mock.overwriteFlags.overwriteCloudGraphConfig
244 ) {
245 // Test config for cloudgraph configuration changes
246 originalConfigFile.cloudGraph = mock.expectedResult
247 expect(newConfigFile).toMatchObject(originalConfigFile)
248 }
249}
250
251export const initTestSuite = (
252 args: {

Callers 1

init.test.tsFile · 0.90

Calls 4

getInitCommandFunction · 0.85
removeConfigFileFunction · 0.85
getConfigFileFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected