message: chore(scaffolder): fixing some tests with it creating bad tmp dirs
diff: @@ -33,12 +33,15 @@ describe('CookieCutter Templater', () => {
  beforeEach(async () => {
  jest.clearAllMocks();
  -
  - await fs.remove(`${os.tmpdir()}/cookiecutter.json`);
  });
  + const mkTemp = async () => {
  + const tempDir = os.tmpdir();
  + return await fs.promises.mkdtemp(tempDir);
  + };
  +
  it('should write a cookiecutter.json file with the values from the entitiy', async () => {
  - const tempdir = os.tmpdir();
  + const tempdir = await mkTemp();
  const values = {
  component_id: 'test',
  @@ -53,10 +56,11 @@ describe('CookieCutter Templater', () => {
  });
  it('should merge any value that is in the cookiecutter.json path already', async () => {
  - const tempdir = os.tmpdir();
  + const tempdir = await mkTemp();
  const existingJson = {
  _copy_without_render: ['./github/workflows/*'],
  };
  +
  await fs.writeJSON(`${tempdir}/cookiecutter.json`, existingJson);
  const values = {
  @@ -72,7 +76,7 @@ describe('CookieCutter Templater', () => {
  });
  it('should throw an error if the cookiecutter json is malformed and not missing', async () => {
  - const tempdir = os.tmpdir();
  + const tempdir = await mkTemp();
  await fs.writeFile(`${tempdir}/cookiecutter.json`, "{'");
  @@ -87,7 +91,7 @@ describe('CookieCutter Templater', () => {
  });
  it('should run the correct docker container with the correct bindings for the volumes', async () => {
  - const tempdir = os.tmpdir();
  + const tempdir = await mkTemp();
  const values = {
  component_id: 'test',
  @@ -97,8 +101,15 @@ describe('CookieCutter Templater', () => {
  await cookie.run({ directory: tempdir, values, dockerClient: mockDocker });
  expect(runDockerContainer).toHaveBeenCalledWith({
  - imageName: 'backstage/cookiecutter',
  - args: ['cookiecutter', '--no-input', '-o', '/result', '/template'],
  + imageName: 'spotify/backstage-cookiecutter',
  + args: [
  + 'cookiecutter',
  + '--no-input',
  + '-o',
  + '/result',
  + '/template',
  + '--verbose',
  + ],
  templateDir: tempdir,
  resultDir: expect.stringContaining(`${tempdir}-result`),
  logStream: undefined,
  @@ -107,7 +118,7 @@ describe('CookieCutter Templater', () => {
  });
  it('should return the result path to the end templated folder', async () => {
  - const tempdir = os.tmpdir();
  + const tempdir = await mkTemp();
  const values = {
  component_id: 'test',
  @@ -126,7 +137,7 @@ describe('CookieCutter Templater', () => {
  it('should pass through the streamer to the run docker helper', async () => {
  const stream = new PassThrough();
  - const tempdir = os.tmpdir();
  + const tempdir = await mkTemp();
  const values = {
  component_id: 'test',
  @@ -141,8 +152,15 @@ describe('CookieCutter Templater', () => {
  });
  expect(runDockerContainer).toHaveBeenCalledWith({
  - imageName: 'backstage/cookiecutter',
  - args: ['cookiecutter', '--no-input', '-o', '/result', '/template'],
  + imageName: 'spotify/backstage-cookiecutter',
  + args: [
  + 'cookiecutter',
  + '--no-input',
  + '-o',
  + '/result',
  + '/template',
  + '--verbose',
  + ],
  templateDir: tempdir,
  resultDir: expect.stringContaining(`${tempdir}-result`),
  logStream: stream,
  