Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/test_vagrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ def test_vm_lifecycle(vm_dir):
assert v.NOT_CREATED == v.status()[0].state


def test_valid_config(vm_dir):
v = vagrant.Vagrant(vm_dir)
v.up()
validation = v.validate(vm_dir)

assert validation.returncode == 0


def test_vm_config(vm_dir):
"""
Test methods retrieving ssh config settings, like user, hostname, and port.
Expand Down
14 changes: 14 additions & 0 deletions vagrant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,20 @@ def plugin_list(self):
output = self._run_vagrant_command(["plugin", "list", "--machine-readable"])
return self._parse_plugin_list(output)

def validate(self, directory):
"""
This command validates present Vagrantfile.
"""
validate = subprocess.run(
["vagrant", "validate"],
cwd=directory,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)

return validate

def _parse_plugin_list(self, output):
"""
Remove Vagrant from the equation for unit testing.
Expand Down