mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-26 13:03:37 +00:00
feat: add test for cleanup
This commit is contained in:
parent
f6ec85149b
commit
7b7ad1617b
7 changed files with 26002 additions and 42 deletions
36
cleanup/test/cleanup.test.js
Normal file
36
cleanup/test/cleanup.test.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
describe('Cleanup Test Suite', () => {
|
||||
it('post-jobs cleanup step', async () => {
|
||||
// Create test directory structure
|
||||
const testDir = 'testDir';
|
||||
if (!fs.existsSync(testDir)) {
|
||||
fs.mkdirSync(testDir, { recursive: true });
|
||||
}
|
||||
fs.writeFileSync(path.join(testDir, 'testFile.txt'), 'test content');
|
||||
|
||||
// Call your cleanup function
|
||||
execSync('node cleanup/cleanup', {
|
||||
env: {
|
||||
...process.env,
|
||||
TERRAFORM_CLI_PATH: testDir,
|
||||
INPUT_CLEANUP_WORKSPACE: 'true'
|
||||
}
|
||||
});
|
||||
|
||||
// Test assertions
|
||||
try {
|
||||
assert.strictEqual(fs.existsSync(testDir), false, 'Directory should be deleted');
|
||||
} catch (error) {
|
||||
console.error('Test failed:', error.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue