This commit is contained in:
Brandon Croft 2025-12-16 15:57:36 +00:00 committed by GitHub
commit fefd48d0f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 44 additions and 70 deletions

View file

@ -28,18 +28,12 @@ const setup = require('../lib/setup-terraform');
// .fn(console.error);
describe('Setup Terraform', () => {
const HOME = process.env.HOME;
const APPDATA = process.env.APPDATA;
beforeEach(() => {
process.env.HOME = '/tmp/asdf';
process.env.APPDATA = '/tmp/asdf';
process.env.RUNNER_TEMP = '/tmp/asdf';
});
afterEach(async () => {
await io.rmRF(process.env.HOME);
process.env.HOME = HOME;
process.env.APPDATA = APPDATA;
await io.rmRF(process.env.RUNNER_TEMP);
});
test('gets specific version and adds token and hostname on linux, amd64', async () => {
@ -78,8 +72,8 @@ describe('Setup Terraform', () => {
// downloaded CLI has been added to path
expect(core.addPath).toHaveBeenCalled();
// expect credentials are in ${HOME}.terraformrc
const creds = await fs.readFile(`${process.env.HOME}/.terraformrc`, { encoding: 'utf8' });
// expect credentials are in ${RUNNER_TEMP}/setup-terraform.tfrc
const creds = await fs.readFile(`${process.env.RUNNER_TEMP}/setup-terraform.tfrc`, { encoding: 'utf8' });
expect(creds.indexOf(credentialsHostname)).toBeGreaterThan(-1);
expect(creds.indexOf(credentialsToken)).toBeGreaterThan(-1);
});
@ -123,8 +117,8 @@ describe('Setup Terraform', () => {
// downloaded CLI has been added to path
expect(core.addPath).toHaveBeenCalled();
// expect credentials are in ${HOME}.terraformrc
const creds = await fs.readFile(`${process.env.HOME}/terraform.rc`, { encoding: 'utf8' });
// expect credentials are in ${RUNNER_TEMP}/setup-terraform.tfrc
const creds = await fs.readFile(`${process.env.RUNNER_TEMP}/setup-terraform.tfrc`, { encoding: 'utf8' });
expect(creds.indexOf(credentialsHostname)).toBeGreaterThan(-1);
expect(creds.indexOf(credentialsToken)).toBeGreaterThan(-1);
});
@ -166,8 +160,8 @@ describe('Setup Terraform', () => {
// downloaded CLI has been added to path
expect(core.addPath).toHaveBeenCalled();
// expect credentials are in ${HOME}.terraformrc
const creds = await fs.readFile(`${process.env.HOME}/.terraformrc`, { encoding: 'utf8' });
// expect credentials are in ${RUNNER_TEMP}/setup-terraform.tfrc
const creds = await fs.readFile(`${process.env.RUNNER_TEMP}/setup-terraform.tfrc`, { encoding: 'utf8' });
expect(creds.indexOf(credentialsHostname)).toBeGreaterThan(-1);
expect(creds.indexOf(credentialsToken)).toBeGreaterThan(-1);
});
@ -209,8 +203,8 @@ describe('Setup Terraform', () => {
// downloaded CLI has been added to path
expect(core.addPath).toHaveBeenCalled();
// expect credentials are in ${HOME}.terraformrc
const creds = await fs.readFile(`${process.env.HOME}/.terraformrc`, { encoding: 'utf8' });
// expect credentials are in ${RUNNER_TEMP}/setup-terraform.tfrc
const creds = await fs.readFile(`${process.env.RUNNER_TEMP}/setup-terraform.tfrc`, { encoding: 'utf8' });
expect(creds.indexOf(credentialsHostname)).toBeGreaterThan(-1);
expect(creds.indexOf(credentialsToken)).toBeGreaterThan(-1);
});
@ -251,8 +245,8 @@ describe('Setup Terraform', () => {
// downloaded CLI has been added to path
expect(core.addPath).toHaveBeenCalled();
// expect credentials are in ${HOME}.terraformrc
const creds = await fs.readFile(`${process.env.HOME}/.terraformrc`, { encoding: 'utf8' });
// expect credentials are in ${RUNNER_TEMP}/setup-terraform.tfrc
const creds = await fs.readFile(`${process.env.RUNNER_TEMP}/setup-terraform.tfrc`, { encoding: 'utf8' });
expect(creds.indexOf(credentialsHostname)).toBeGreaterThan(-1);
expect(creds.indexOf(credentialsToken)).toBeGreaterThan(-1);
});
@ -293,8 +287,8 @@ describe('Setup Terraform', () => {
// downloaded CLI has been added to path
expect(core.addPath).toHaveBeenCalled();
// expect credentials are in ${HOME}.terraformrc
const creds = await fs.readFile(`${process.env.HOME}/.terraformrc`, { encoding: 'utf8' });
// expect credentials are in ${RUNNER_TEMP}/setup-terraform.tfrc
const creds = await fs.readFile(`${process.env.RUNNER_TEMP}/setup-terraform.tfrc`, { encoding: 'utf8' });
expect(creds.indexOf(credentialsHostname)).toBeGreaterThan(-1);
expect(creds.indexOf(credentialsToken)).toBeGreaterThan(-1);
});
@ -335,8 +329,8 @@ describe('Setup Terraform', () => {
// downloaded CLI has been added to path
expect(core.addPath).toHaveBeenCalled();
// expect credentials are in ${HOME}.terraformrc
const creds = await fs.readFile(`${process.env.HOME}/.terraformrc`, { encoding: 'utf8' });
// expect credentials are in ${RUNNER_TEMP}/setup-terraform.tfrc
const creds = await fs.readFile(`${process.env.RUNNER_TEMP}/setup-terraform.tfrc`, { encoding: 'utf8' });
expect(creds.indexOf(credentialsHostname)).toBeGreaterThan(-1);
expect(creds.indexOf(credentialsToken)).toBeGreaterThan(-1);
});
@ -377,8 +371,8 @@ describe('Setup Terraform', () => {
// downloaded CLI has been added to path
expect(core.addPath).toHaveBeenCalled();
// expect credentials are in ${HOME}.terraformrc
const creds = await fs.readFile(`${process.env.HOME}/.terraformrc`, { encoding: 'utf8' });
// expect credentials are in ${RUNNER_TEMP}/setup-terraform.tfrc
const creds = await fs.readFile(`${process.env.RUNNER_TEMP}/setup-terraform.tfrc`, { encoding: 'utf8' });
expect(creds.indexOf(credentialsHostname)).toBeGreaterThan(-1);
expect(creds.indexOf(credentialsToken)).toBeGreaterThan(-1);
});
@ -419,8 +413,8 @@ describe('Setup Terraform', () => {
// downloaded CLI has been added to path
expect(core.addPath).toHaveBeenCalled();
// expect credentials are in ${HOME}.terraformrc
const creds = await fs.readFile(`${process.env.HOME}/.terraformrc`, { encoding: 'utf8' });
// expect credentials are in ${RUNNER_TEMP}/setup-terraform.tfrc
const creds = await fs.readFile(`${process.env.RUNNER_TEMP}/setup-terraform.tfrc`, { encoding: 'utf8' });
expect(creds.indexOf(credentialsHostname)).toBeGreaterThan(-1);
expect(creds.indexOf(credentialsToken)).toBeGreaterThan(-1);
});