Merge pull request #1865 from NoahGorny/add-profile-subcommand
add profile subcommand
This commit is contained in:
@@ -80,32 +80,42 @@ function __check_completion () {
|
||||
|
||||
@test "completion bash-it: show options" {
|
||||
run __check_completion 'bash-it '
|
||||
assert_line -n 0 "disable enable help migrate reload restart doctor search show update version"
|
||||
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version"
|
||||
}
|
||||
|
||||
@test "completion bash-it: bash-ti - show options" {
|
||||
run __check_completion 'bash-ti '
|
||||
assert_line -n 0 "disable enable help migrate reload restart doctor search show update version"
|
||||
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version"
|
||||
}
|
||||
|
||||
@test "completion bash-it: shit - show options" {
|
||||
run __check_completion 'shit '
|
||||
assert_line -n 0 "disable enable help migrate reload restart doctor search show update version"
|
||||
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version"
|
||||
}
|
||||
|
||||
@test "completion bash-it: bashit - show options" {
|
||||
run __check_completion 'bashit '
|
||||
assert_line -n 0 "disable enable help migrate reload restart doctor search show update version"
|
||||
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version"
|
||||
}
|
||||
|
||||
@test "completion bash-it: batshit - show options" {
|
||||
run __check_completion 'batshit '
|
||||
assert_line -n 0 "disable enable help migrate reload restart doctor search show update version"
|
||||
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version"
|
||||
}
|
||||
|
||||
@test "completion bash-it: bash_it - show options" {
|
||||
run __check_completion 'bash_it '
|
||||
assert_line -n 0 "disable enable help migrate reload restart doctor search show update version"
|
||||
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version"
|
||||
}
|
||||
|
||||
@test "completion bash-it: profile - show options" {
|
||||
run __check_completion 'bash-it profile '
|
||||
assert_line -n 0 "load save list rm"
|
||||
}
|
||||
|
||||
@test "completion bash-it: profile load - show options" {
|
||||
run __check_completion 'bash-it profile load '
|
||||
assert_line -n 0 "default"
|
||||
}
|
||||
|
||||
@test "completion bash-it: show - show options" {
|
||||
|
||||
12
test/fixtures/bash_it/profiles/test-bad-component.bash_it
vendored
Normal file
12
test/fixtures/bash_it/profiles/test-bad-component.bash_it
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# plugins
|
||||
plugins alias-completion
|
||||
plugins base
|
||||
|
||||
# completion
|
||||
completion bash-it
|
||||
completion system
|
||||
|
||||
# aliases
|
||||
aliases general
|
||||
# Bad component
|
||||
aliases bla
|
||||
12
test/fixtures/bash_it/profiles/test-bad-type.bash_it
vendored
Normal file
12
test/fixtures/bash_it/profiles/test-bad-type.bash_it
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# plugins
|
||||
plugins alias-completion
|
||||
plugins base
|
||||
# Bad type
|
||||
pluugins alias-completion
|
||||
|
||||
# completion
|
||||
completion bash-it
|
||||
completion system
|
||||
|
||||
# aliases
|
||||
aliases general
|
||||
@@ -13,11 +13,24 @@ load ../../plugins/available/base.plugin
|
||||
|
||||
function local_setup {
|
||||
setup_test_fixture
|
||||
|
||||
# Copy the test fixture to the Bash-it folder
|
||||
if command -v rsync &> /dev/null; then
|
||||
rsync -a "$BASH_IT/test/fixtures/bash_it/" "$BASH_IT/"
|
||||
else
|
||||
find "$BASH_IT/test/fixtures/bash_it" \
|
||||
-mindepth 1 -maxdepth 1 \
|
||||
-exec cp -r {} "$BASH_IT/" \;
|
||||
fi
|
||||
}
|
||||
|
||||
# TODO Create global __is_enabled function
|
||||
# TODO Create global __get_base_name function
|
||||
# TODO Create global __get_enabled_name function
|
||||
@test "bash-it: verify that the test fixture is available" {
|
||||
assert_file_exist "$BASH_IT/profiles/test-bad-component.bash_it"
|
||||
assert_file_exist "$BASH_IT/profiles/test-bad-type.bash_it"
|
||||
}
|
||||
|
||||
@test "helpers: _command_exists function exists" {
|
||||
run type -a _command_exists &> /dev/null
|
||||
@@ -283,6 +296,149 @@ function local_setup {
|
||||
assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash"
|
||||
}
|
||||
|
||||
@test "helper: profile load command sanity" {
|
||||
run _bash-it-profile-load "default"
|
||||
|
||||
assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash"
|
||||
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"
|
||||
assert_link_exist "$BASH_IT/enabled/365---alias-completion.plugin.bash"
|
||||
assert_link_exist "$BASH_IT/enabled/350---bash-it.completion.bash"
|
||||
assert_link_exist "$BASH_IT/enabled/350---system.completion.bash"
|
||||
}
|
||||
|
||||
@test "helper: profile save command sanity" {
|
||||
run _enable-plugin "nvm"
|
||||
|
||||
run _bash-it-profile-save "test"
|
||||
assert_line -n 0 "Saving plugins configuration..."
|
||||
assert_line -n 1 "Saving completion configuration..."
|
||||
assert_line -n 2 "Saving aliases configuration..."
|
||||
assert_line -n 3 "All done!"
|
||||
assert_file_exist "$BASH_IT/profiles/test.bash_it"
|
||||
}
|
||||
|
||||
@test "helper: profile save creates valid file with only plugin enabled" {
|
||||
run _enable-plugin "nvm"
|
||||
|
||||
run _bash-it-profile-save "test"
|
||||
run cat "$BASH_IT/profiles/test.bash_it"
|
||||
assert_line -n 0 "# This file is auto generated by Bash-it. Do not edit manually!"
|
||||
assert_line -n 1 "# plugins"
|
||||
assert_line -n 2 "plugins nvm"
|
||||
}
|
||||
|
||||
@test "helper: profile save creates valid file with only completion enabled" {
|
||||
run _enable-completion "bash-it"
|
||||
|
||||
run _bash-it-profile-save "test"
|
||||
run cat "$BASH_IT/profiles/test.bash_it"
|
||||
assert_line -n 0 "# This file is auto generated by Bash-it. Do not edit manually!"
|
||||
assert_line -n 1 "# completion"
|
||||
assert_line -n 2 "completion bash-it"
|
||||
}
|
||||
|
||||
@test "helper: profile save creates valid file with only aliases enabled" {
|
||||
run _enable-alias "general"
|
||||
|
||||
run _bash-it-profile-save "test"
|
||||
run cat "$BASH_IT/profiles/test.bash_it"
|
||||
assert_line -n 0 "# This file is auto generated by Bash-it. Do not edit manually!"
|
||||
assert_line -n 1 "# aliases"
|
||||
assert_line -n 2 "aliases general"
|
||||
}
|
||||
|
||||
@test "helper: profile edge case, empty configuration" {
|
||||
run _bash-it-profile-save "test"
|
||||
assert_line -n 3 "It seems like no configuration was enabled.."
|
||||
assert_line -n 4 "Make sure to double check that this is the wanted behavior."
|
||||
|
||||
run _enable-alias "general"
|
||||
run _enable-plugin "base"
|
||||
run _enable-plugin "alias-completion"
|
||||
run _enable-completion "bash-it"
|
||||
run _enable-completion "system"
|
||||
|
||||
run _bash-it-profile-load "test"
|
||||
assert_link_not_exist "$BASH_IT/enabled/150---general.aliases.bash"
|
||||
assert_link_not_exist "$BASH_IT/enabled/250---base.plugin.bash"
|
||||
assert_link_not_exist "$BASH_IT/enabled/365---alias-completion.plugin.bash"
|
||||
assert_link_not_exist "$BASH_IT/enabled/350---bash-it.completion.bash"
|
||||
assert_link_not_exist "$BASH_IT/enabled/350---system.completion.bash"
|
||||
}
|
||||
|
||||
@test "helper: profile save and load" {
|
||||
run _enable-alias "general"
|
||||
run _enable-plugin "base"
|
||||
run _enable-plugin "alias-completion"
|
||||
run _enable-completion "bash-it"
|
||||
run _enable-completion "system"
|
||||
|
||||
run _bash-it-profile-save "test"
|
||||
assert_success
|
||||
|
||||
run _disable-alias "general"
|
||||
assert_link_not_exist "$BASH_IT/enabled/150---general.aliases.bash"
|
||||
run _bash-it-profile-load "test"
|
||||
assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash"
|
||||
}
|
||||
|
||||
@test "helper: profile load corrupted profile file: bad component" {
|
||||
run _bash-it-profile-load "test-bad-component"
|
||||
assert_line -n 1 -p "Bad line(#12) in profile, aborting load..."
|
||||
}
|
||||
|
||||
@test "helper: profile load corrupted profile file: bad subdirectory" {
|
||||
run _bash-it-profile-load "test-bad-type"
|
||||
assert_line -n 1 -p "Bad line(#5) in profile, aborting load..."
|
||||
}
|
||||
|
||||
@test "helper: profile rm sanity" {
|
||||
run _bash-it-profile-save "test"
|
||||
assert_file_exist "$BASH_IT/profiles/test.bash_it"
|
||||
run _bash-it-profile-rm "test"
|
||||
assert_line -n 0 "Removed profile \"test\" successfully!"
|
||||
assert_file_not_exist "$BASH_IT/profiles/test.bash_it"
|
||||
}
|
||||
|
||||
@test "helper: profile rm no params" {
|
||||
run _bash-it-profile-rm ""
|
||||
assert_line -n 0 -p "Please specify profile name to remove..."
|
||||
}
|
||||
|
||||
@test "helper: profile load no params" {
|
||||
run _bash-it-profile-load ""
|
||||
assert_line -n 0 -p "Please specify profile name to load, not changing configuration..."
|
||||
}
|
||||
|
||||
@test "helper: profile rm default" {
|
||||
run _bash-it-profile-rm "default"
|
||||
assert_line -n 0 -p "Can not remove the default profile..."
|
||||
assert_file_exist "$BASH_IT/profiles/default.bash_it"
|
||||
}
|
||||
|
||||
@test "helper: profile rm bad profile name" {
|
||||
run _bash-it-profile-rm "notexisting"
|
||||
assert_line -n 0 -p "Could not find profile \"notexisting\"..."
|
||||
}
|
||||
|
||||
@test "helper: profile list sanity" {
|
||||
run _bash-it-profile-list
|
||||
assert_line -n 0 "Available profiles:"
|
||||
assert_line -n 1 "default"
|
||||
}
|
||||
|
||||
@test "helper: profile list more profiles" {
|
||||
run _bash-it-profile-save "cactus"
|
||||
run _bash-it-profile-save "another"
|
||||
run _bash-it-profile-save "brother"
|
||||
run _bash-it-profile-list
|
||||
assert_line -n 0 "Available profiles:"
|
||||
assert_line -n 4 "default"
|
||||
assert_line -n 3 "cactus"
|
||||
assert_line -n 1 "another"
|
||||
assert_line -n 2 "brother"
|
||||
}
|
||||
|
||||
@test "helpers: migrate plugins and completions that share the same name" {
|
||||
ln -s $BASH_IT/completion/available/dirs.completion.bash $BASH_IT/completion/enabled/350---dirs.completion.bash
|
||||
assert_link_exist "$BASH_IT/completion/enabled/350---dirs.completion.bash"
|
||||
|
||||
Reference in New Issue
Block a user