Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test against infinite prompt during cluster setup #1031

Merged
merged 4 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/dcoscli/package/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def _install(package_name, package_version, options_path, app_id, cli,

if not confirm('Continue installing?', yes):
emitter.publish('Exiting installation.')
return 0
return 1

if app and pkg.marathon_template():

Expand Down
17 changes: 16 additions & 1 deletion cli/tests/integrations/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import contextlib
import json
import os
import subprocess
import sys

import pytest
Expand Down Expand Up @@ -416,6 +417,19 @@ def test_install_bad_package_version():
stderr=stderr)


def test_install_noninteractive():
try:
returncode, stdout, _ = exec_command(
['dcos', 'package', 'install', 'hello-world'],
timeout=30,
stdin=subprocess.DEVNULL)
except subprocess.TimeoutExpired:
assert False, 'timed out waiting for process to exit'

assert returncode == 1
assert b"'' is not a valid response" in stdout


def test_package_metadata():
_install_helloworld()

Expand Down Expand Up @@ -683,7 +697,8 @@ def test_install_no():
b'catalog-terms-conditions/#community-services\n'
b'A sample pre-installation message\n'
b'Continue installing? [yes/no] Exiting installation.\n'
)
),
returncode=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. At first I thought this seemed strange to return a 1 if the user supplied no as valid input. The reason being that the command exits cleanly, whether the user inputs yes or no (the only difference being whether the package was actually installed or not). I would have expected a 1 only if there was some internal error that made the command exit prematurely.

On thinking about it a bit more though, I agree with the semantics you have in place. Use a 0 to indicate that the command successfully carried out what you asked it to; use a 1 to indicate that it didn't.

An example demonstrating these semantics in a standard unix environment:

$ ls
foo        bar        baz
$ ls | grep foo
$ echo $?
0
$ ls | grep qux
$ echo $?
1

)


Expand Down