Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Mar 16, 2018
1 parent f6a32b8 commit 4e8e36b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/registration/ui/offline_migration_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ module UI
# This class handles offline migration workflow,
# it is a wrapper around "migration_repos" client
class OfflineMigrationWorkflow
include Yast::I18n
include Yast::Logger

# the constructor
def initialize
textdomain "registration"
Expand Down
34 changes: 34 additions & 0 deletions test/offline_migration_workflow_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/env rspec

require_relative "spec_helper"

describe Registration::UI::OfflineMigrationWorkflow do
describe "#main" do
it "runs the 'migration_repos' client" do
expect(Yast::WFM).to receive(:CallFunction).with("migration_repos", anything)
subject.main
end

it "returns the 'migration_repos' result" do
expect(Yast::WFM).to receive(:CallFunction).with("migration_repos", anything).and_return(:foo)
expect(subject.main).to eq(:foo)
end

context "the 'migration_repos' client returns :rollback" do
before do
expect(Yast::WFM).to receive(:CallFunction).with("migration_repos", anything)
.and_return(:rollback)
allow(Yast::WFM).to receive(:CallFunction).with("registration_sync")
end

it "runs the 'registration_sync' client" do
expect(Yast::WFM).to receive(:CallFunction).with("registration_sync")
subject.main
end

it "return :back" do
expect(subject.main).to eq(:back)
end
end
end
end

0 comments on commit 4e8e36b

Please sign in to comment.