Skip to content

Commit

Permalink
Print state as output of install and switch command
Browse files Browse the repository at this point in the history
  • Loading branch information
hidakatsuya committed Aug 13, 2024
1 parent ae8534f commit ffa8f76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
6 changes: 6 additions & 0 deletions lib/rex/commands/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def install_initially(definition)
install(definition.themes, definition.plugins)

create_lock_file(definition.env)
print_state
end

def apply_diff(lock_definition, definition)
Expand All @@ -30,6 +31,7 @@ def apply_diff(lock_definition, definition)
update(diff.changed_themes, diff.changed_plugins)

create_lock_file(definition.env)
print_state
end

def load_definition(env)
Expand Down Expand Up @@ -75,6 +77,10 @@ def update(themes, plugins)
def create_lock_file(env)
Definition::Lock.create_file(env)
end

def print_state
State.new.call
end
end
end
end
33 changes: 10 additions & 23 deletions test/integration/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ class IntegrationTest < Test::Unit::TestCase

docker_exec("rex install").then do |result|
assert_true result.success?
assert_equal "", result.output_str
assert_equal [
"Rex: 0.1.0",
"Env: default",
"",
"Themes:",
" * theme_a (master)",
"",
"Plugins:",
" * plugin_a (master)"
], result.output
end

docker_exec("ls plugins").then do |result|
Expand All @@ -42,19 +51,6 @@ class IntegrationTest < Test::Unit::TestCase
assert_equal "hellos", result.output_str
end

docker_exec("rex state").then do |result|
assert_equal [
"Rex: 0.1.0",
"Env: default",
"",
"Themes:",
" * theme_a (master)",
"",
"Plugins:",
" * plugin_a (master)"
], result.output
end

docker_exec("rex uninstall").then do |result|
assert_true result.success?
assert_equal "", result.output_str
Expand All @@ -75,17 +71,12 @@ class IntegrationTest < Test::Unit::TestCase

test "rex switch" do
docker_exec("rex switch").then do |result|
puts result
assert_true result.success?
assert_equal "No lock file found", result.output_str
end

docker_exec("rex install env1").then do |result|
assert_true result.success?
assert_equal "", result.output_str
end

docker_exec("rex state").then do |result|
assert_equal [
"Rex: 0.1.0",
"Env: env1",
Expand All @@ -97,10 +88,6 @@ class IntegrationTest < Test::Unit::TestCase

docker_exec("rex switch env2").then do |result|
assert_true result.success?
assert_equal "", result.output_str
end

docker_exec("rex state").then do |result|
assert_equal [
"Rex: 0.1.0",
"Env: env2",
Expand Down

0 comments on commit ffa8f76

Please sign in to comment.