import { promises as fs } from 'fs';
import * as path from 'path';
import { integTest, withCDKMigrateFixture } from '../../../lib';

jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime

integTest(
  'cdk migrate generates migrate.json',
  withCDKMigrateFixture('typescript', async (fixture) => {
    const migrateFile = await fs.readFile(path.join(fixture.integTestDir, 'migrate.json'), 'utf8');
    const expectedFile = `{
    \"//\": \"This file is generated by cdk migrate. It will be automatically deleted after the first successful deployment of this app to the environment of the original resources.\",
    \"Source\": \"localfile\"
  }`;
    expect(JSON.parse(migrateFile)).toEqual(JSON.parse(expectedFile));
    await fixture.cdkDestroy(fixture.stackNamePrefix);
  }),
);


