-
Notifications
You must be signed in to change notification settings - Fork 44
/
inst_casp_overview_test.rb
executable file
·136 lines (105 loc) · 3.25 KB
/
inst_casp_overview_test.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#! /usr/bin/env rspec
require_relative "test_helper"
require "installation/clients/inst_casp_overview"
Yast.import "CWM"
Yast.import "Language"
Yast.import "Mode"
Yast.import "Pkg"
Yast.import "Popup"
Yast.import "Wizard"
# stub tune widgets used in dialog
require "cwm/widget"
module Tune
module Widgets
class SystemInformation < CWM::PushButton
def label
"System Information"
end
end
end
end
module Registration
module Widgets
class RegistrationCode < CWM::InputField
def label
"Registration code"
end
end
end
end
module Users
class PasswordWidget < CWM::CustomWidget
def initialize(little_space: true)
end
def label
"Password"
end
end
end
module Y2Country
module Widgets
class KeyboardSelectionCombo < CWM::ComboBox
def initialize(_language)
end
def label
"Keyboard"
end
end
end
end
describe ::Installation::InstCaspOverview do
describe "#run" do
before do
allow(Yast::Wizard).to receive(:CreateDialog)
allow(Yast::Wizard).to receive(:CloseDialog)
allow(Yast::Pkg).to receive(:SetPackageLocale)
allow(Yast::CWM).to receive(:show).and_return(:next)
allow(Yast::Language).to receive(:language).and_return("en_US")
allow(Yast::WFM).to receive(:CallFunction).and_return({})
allow(Yast::WFM).to receive(:CallFunction)
.with("inst_doit", []).and_return(:next)
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:exist?).with("/info.txt").and_return(false)
end
it "sets package locale same as Language" do
expect(Yast::Pkg).to receive(:SetPackageLocale).with(Yast::Language.language)
subject.run
end
it "creates wizard dialog in normal mode" do
allow(Yast::Mode).to receive(:normal).and_return(true)
expect(Yast::Wizard).to receive(:CreateDialog)
subject.run
end
it "closed wizard dialog in normal mode" do
allow(Yast::Mode).to receive(:normal).and_return(true)
expect(Yast::Wizard).to receive(:CloseDialog)
subject.run
end
it "shows CWM widgets" do
allow(Yast::Mode).to receive(:normal).and_return(true)
expect(Yast::CWM).to receive(:show).and_return(:next)
subject.run
end
it "shows CWM widgets again if it returns redraw event" do
allow(Yast::Mode).to receive(:normal).and_return(true)
expect(Yast::CWM).to receive(:show).twice.and_return(:redraw, :next)
subject.run
end
it "adds caasp specific services to be enabled" do
subject.run
expect(::Installation::Services.enabled).to include("cloud-init")
end
it "displays the /info.txt file if it exists" do
expect(File).to receive(:exist?).with("/info.txt").and_return(true)
expect(Yast::InstShowInfo).to receive(:show_info_txt).with("/info.txt").and_return(true)
expect(Yast::CWM).to receive(:show).and_return(:next)
subject.run
end
it "does not try displaying the /info.txt file if it does not exist" do
expect(File).to receive(:exist?).with("/info.txt").and_return(false)
expect(Yast::InstShowInfo).to_not receive(:show_info_txt)
expect(Yast::CWM).to receive(:show).and_return(:next)
subject.run
end
end
end