Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Aug 16, 2024
1 parent 162dc04 commit 92f6a5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions spec/fixtures/bad_hcl_vars.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo = "bar
16 changes: 13 additions & 3 deletions spec/linter-packer-validate-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('The Packer Validate provider for Linter', () => {
);
});

it('checks an invalid non-packer hcl template and does nothing', (done) => {
it('checks an invalid non-packer hcl template and emits no messages to the linter UI', (done) => {
const otherFile = path.join(__dirname, 'fixtures/', 'bad_hcl_not_packer.hcl');
return atom.workspace.open(otherFile).then(editor =>
lint(editor).then(messages => {
Expand All @@ -35,6 +35,16 @@ describe('The Packer Validate provider for Linter', () => {
);
});

it('checks an invalid packer vars hcl file and does nothing', (done) => {
const otherFile = path.join(__dirname, 'fixtures/', 'bad_hcl_vars.pkrvars.hcl');
return atom.workspace.open(otherFile).then(editor =>
lint(editor).then(messages => {
}, () => {
done();
})
);
});

describe('checks a packer hcl template with hcl errors', () => {
let editor = null;
const badFile = path.join(__dirname, 'fixtures/', 'bad_hcl_bad_packer.pkr.hcl');
Expand Down Expand Up @@ -95,7 +105,7 @@ describe('The Packer Validate provider for Linter', () => {
expect(messages[0].severity).toBeDefined();
expect(messages[0].severity).toEqual('error');
expect(messages[0].excerpt).toBeDefined();
expect(messages[0].excerpt).toEqual('This configuration does not support Packer version 1.9.5. To proceed, either choose another supported Packer version or update this version constraint. Version constraints are normally set for good reason, so updating the constraint may lead to other errors or unexpected behavior.');
expect(messages[0].excerpt).toEqual('This configuration does not support Packer version 1.10.3. To proceed, either choose another supported Packer version or update this version constraint. Version constraints are normally set for good reason, so updating the constraint may lead to other errors or unexpected behavior.');
expect(messages[0].location.file).toBeDefined();
expect(messages[0].location.file).toMatch(/.+ok_hcl_extra_packer_comma\.pkr\.hcl$/);
expect(messages[0].location.position).toBeDefined();
Expand Down Expand Up @@ -140,7 +150,7 @@ describe('The Packer Validate provider for Linter', () => {
expect(messages[0].severity).toBeDefined();
expect(messages[0].severity).toEqual('warning');
expect(messages[0].excerpt).toBeDefined();
expect(messages[0].excerpt).toEqual('This template relies on the use of plugins bundled into the Packer binary. The practice of bundling external plugins into Packer will be removed in an upcoming version.');
expect(messages[0].excerpt).toEqual('The source amazon-ebs is unknown by Packer, and is likely part of a plugin that is not installed. You may find the needed plugin along with installation instructions documented on the Packer integrations page.');
expect(messages[0].location.file).toBeDefined();
expect(messages[0].location.file).toMatch(/.+ok_hcl_packer_errors\.pkr\.hcl$/);
expect(messages[0].location.position).toBeDefined();
Expand Down

0 comments on commit 92f6a5e

Please sign in to comment.