-
Notifications
You must be signed in to change notification settings - Fork 19
/
migration_repos_workflow_spec.rb
executable file
·68 lines (53 loc) · 2.44 KB
/
migration_repos_workflow_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#! /usr/bin/env rspec
require_relative "spec_helper"
describe Registration::UI::MigrationReposWorkflow do
describe ".run" do
subject { Registration::UI::MigrationReposWorkflow }
before do
# Url of the registration server
allow(Registration::UrlHelpers).to receive(:registration_url)
# Load source information
allow(Yast::Pkg).to receive(:SourceLoad)
end
it "aborts if package management initialization fails" do
msg = "Initialization failed"
expect(Registration::SwMgmt).to receive(:init).and_return(false)
expect(Yast::Pkg).to receive(:LastError).and_return(msg)
expect(subject.run).to eq(error: true, error_msg: msg)
end
it "handles any exception raised and reports an error" do
msg = "Something failed..."
expect(Yast::Sequencer).to receive(:Run).and_raise(msg)
expect(subject.run).to eq(error: true, error_msg: msg)
end
context "if package management initialization succeeds" do
let(:migrations) { load_yaml_fixture("migation_to_sles12_sp1.yml") }
let(:migration_service) { load_yaml_fixture("migration_service.yml") }
before do
expect(Registration::SwMgmt).to receive(:init).and_return(true)
# installed SLES12
expect(Registration::SwMgmt).to receive(:installed_products)
.and_return([load_yaml_fixture("products_legacy_installation.yml")[1]])
expect_any_instance_of(Registration::RegistrationUI).to receive(:migration_products)
.and_return(migrations)
# user selected a migration and pressed [Next]
expect_any_instance_of(Registration::UI::MigrationSelectionDialog).to receive(:run)
.and_return(:next)
expect_any_instance_of(Registration::UI::MigrationSelectionDialog).to \
receive(:selected_migrations).and_return(migrations)
expect_any_instance_of(Registration::Registration).to receive(:upgrade_product)
.and_return(migration_service)
allow(Registration::SwMgmt).to receive(:service_repos).and_return([])
end
it "registers the selected migration products" do
ret = subject.run
# no error reported
expect(ret).to_not have_key(:aborted)
expect(ret).to_not have_key(:error)
expect(ret[:registered_services].size).to eq(1)
service = ret[:registered_services].first
expect(service[:name]).to eq("SUSE_Linux_Enterprise_Server_12_SP1_12.1_x86_64")
end
end
end
end