-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(version): created the .terraform-version file
- Loading branch information
Showing
11 changed files
with
77 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
export default function () { | ||
return undefined; | ||
import makeDir from 'make-dir'; | ||
|
||
import {scaffold as scaffoldVersion} from './version/index.js'; | ||
|
||
export default async function ({projectRoot}) { | ||
const terraformDirectory = await makeDir(`${projectRoot}/terraform`); | ||
|
||
await scaffoldVersion({terraformDirectory}); | ||
|
||
return {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import makeDir from 'make-dir'; | ||
|
||
import {describe, it, expect, vi} from 'vitest'; | ||
import any from '@travi/any'; | ||
import {when} from 'jest-when'; | ||
|
||
import {scaffold as scaffoldVersion} from './version/index.js'; | ||
import scaffold from './scaffolder.js'; | ||
|
||
vi.mock('make-dir'); | ||
vi.mock('./version/index.js'); | ||
|
||
describe('scaffolder', () => { | ||
it('should scaffold terraform', async () => { | ||
const projectRoot = any.string(); | ||
const createdTerraformDirectory = any.string(); | ||
when(makeDir).calledWith(`${projectRoot}/terraform`).mockResolvedValue(createdTerraformDirectory); | ||
|
||
expect(await scaffold({projectRoot})).toEqual({}); | ||
expect(scaffoldVersion).toHaveBeenCalledWith({terraformDirectory: createdTerraformDirectory}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {default as scaffold} from './scaffolder.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {promises as fs} from 'node:fs'; | ||
|
||
export default async function ({terraformDirectory}) { | ||
await fs.writeFile(`${terraformDirectory}/.terraform-version`, 'v1.8.2'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {promises as fs} from 'node:fs'; | ||
|
||
import any from '@travi/any'; | ||
import {vi, describe, it, expect} from 'vitest'; | ||
|
||
import scaffoldVersion from './scaffolder.js'; | ||
|
||
vi.mock('node:fs'); | ||
|
||
describe('version scaffolder', () => { | ||
it('should create the version file', async () => { | ||
const terraformDirectory = any.string(); | ||
|
||
await scaffoldVersion({terraformDirectory}); | ||
|
||
expect(fs.writeFile).toHaveBeenCalledWith(`${terraformDirectory}/.terraform-version`, 'v1.8.2'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ Feature: Scaffolder | |
|
||
Scenario: Scaffold | ||
When the project is scaffolded | ||
Then the version file is created |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
test/integration/features/step_definitions/version-steps.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {promises as fs} from 'node:fs'; | ||
import assert from 'node:assert'; | ||
|
||
import {Then} from '@cucumber/cucumber'; | ||
|
||
Then('the version file is created', async function () { | ||
const version = await fs.readFile(`${this.projectRoot}/terraform/.terraform-version`, 'utf-8'); | ||
|
||
assert.equal(version, 'v1.8.2'); | ||
}); |