-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds a flag that enables a sort of 'tutorial' mode where an example key is inserted to the stash for the user to try out and `get`
- Loading branch information
David Ginzbourg
committed
May 29, 2017
1 parent
d9fff63
commit fe4f4bf
Showing
3 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
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 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 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 |
---|---|---|
|
@@ -862,6 +862,13 @@ def assert_stash_initialized(stash_path): | |
assert len(db) == 1 | ||
|
||
|
||
def assert_stash_initialized_tutorial(stash_path): | ||
db = get_tinydb(stash_path) | ||
assert '2' in db | ||
assert db['2']['name'] == 'example' | ||
assert len(db) == 2 | ||
|
||
|
||
def assert_key_put(db, dont_verify_value=False): | ||
key = db['2'] | ||
assert key['name'] == 'aws' | ||
|
@@ -1227,7 +1234,7 @@ def test_cli_stash(stash_path): | |
os.close(fd) | ||
os.remove(passphrase_file_path) | ||
ghost.PASSPHRASE_FILENAME = passphrase_file_path | ||
_invoke('init_stash "{0}"'.format(stash_path)) | ||
_invoke('init_stash -s "{0}"'.format(stash_path)) | ||
os.environ['GHOST_STASH_PATH'] = stash_path | ||
with open(passphrase_file_path) as passphrase_file: | ||
passphrase = passphrase_file.read() | ||
|
@@ -1271,7 +1278,7 @@ def test_init(self, test_cli_stash): | |
assert_stash_initialized(test_cli_stash._storage.db_path) | ||
|
||
def test_init_already_initialized(self, test_cli_stash): | ||
result = _invoke('init_stash "{0}" -p {1}'.format( | ||
result = _invoke('init_stash -s "{0}" -p {1}'.format( | ||
os.environ['GHOST_STASH_PATH'], test_cli_stash.passphrase)) | ||
assert 'Stash already initialized' in result.output | ||
assert result.exit_code == 0 | ||
|
@@ -1282,7 +1289,7 @@ def test_init_permission_denied_on_passphrase(self): | |
fd, temp_file = tempfile.mkstemp() | ||
os.close(fd) | ||
os.remove(temp_file) | ||
result = _invoke('init_stash "{0}" -p whatever'.format(temp_file)) | ||
result = _invoke('init_stash -s "{0}" -p whatever'.format(temp_file)) | ||
assert 'Expected OSError' in str(result.exception) | ||
assert 'Removing stale stash and passphrase' in str(result.output) | ||
assert type(result.exception) == SystemExit | ||
|
@@ -1497,8 +1504,8 @@ def test_load(self, test_cli_stash, temp_file_path): | |
def test_fail_init_two_stashes_passphrase_file_exists(self, | ||
stash_path, | ||
temp_file_path): | ||
_invoke('init_stash "{0}"'.format(stash_path)) | ||
result = _invoke('init_stash "{0}" -b sqlalchemy'.format( | ||
_invoke('init_stash -s "{0}"'.format(stash_path)) | ||
result = _invoke('init_stash -s "{0}" -b sqlalchemy'.format( | ||
temp_file_path)) | ||
|
||
assert 'Overwriting might prevent you' in result.output | ||
|
@@ -1642,6 +1649,10 @@ def test_ssh_with_key_path_and_extension(self, test_cli_stash): | |
'ssh -i /path/to/key [email protected] -o Key="Value"' | ||
assert expected_command in str(result.exception) | ||
|
||
def test_tutorial(self, stash_path): | ||
_invoke('init_stash -s "{0}" -t'.format(stash_path)) | ||
assert_stash_initialized_tutorial(stash_path) | ||
|
||
|
||
class TestMultiStash: | ||
# TODO: Test that migrate works when using multi-stash mode | ||
|