def test_whenCalledWithDestroyCommand_shouldAppendVarsAndCreds( self, mocked_get_env): """Case where var-file, -var workpace=xyz and -var shared_credentials is appended""" self.input_args.command = "destroy" mocked_get_env.return_value = "mytestenv" atmos.determine_actions(self.input_args, []) atmos.run_cmd.assert_called_with( 'terraform destroy -var-file=vars/mytestenv.tfvars -var "workspace=mytestenv" -var "shared_credentials_file=$HOME/.aws/credentials"' )
def test_whenEnvironmentArgIsGiven_shouldGenerateCredentials( self, mocked_generate): self.input_args.e = True atmos.determine_actions(self.input_args, []) mocked_generate.assert_called_once()
def test_whenInAGitRepo_andManualArgIsNotGiven_andEnvironmentArgIsNotGiven_shouldCallTheWorkspaceManager( self, mocked_workspace_manager): atmos.is_git_directory.return_value = True atmos.determine_actions(self.input_args, []) mocked_workspace_manager.assert_called_once()
def test_whenCalledWithParams_theyAreAppended(self): """Should append all params after the command""" atmos.determine_actions(self.input_args, ["--myparam", "myvalue"]) atmos.run_cmd.assert_called_with( "terraform mytestcommand --myparam myvalue")
def test_whenCalledWithNoAdditionalArgs_shouldRunTheTerraformCommand(self): """Simplest case where atmos is only called with a command and no further arguments""" atmos.determine_actions(self.input_args, []) atmos.run_cmd.assert_called_with("terraform mytestcommand")