/
Timezone_test.rb
executable file
·116 lines (88 loc) · 3 KB
/
Timezone_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
#!/usr/bin/env rspec
require_relative "test_helper"
Yast.import "Timezone"
Yast.import "ProductFeatures"
describe Yast::Timezone do
let(:readonly_timezone) { false }
let(:default_timezone) { "" }
let(:initial) { false }
before do
allow(Yast::ProductFeatures).to receive(:GetBooleanFeature)
.with("globals", "readonly_timezone").and_return(readonly_timezone)
allow(Yast::ProductFeatures).to receive(:GetStringFeature)
.with("globals", "timezone").and_return(default_timezone)
allow(Yast::Stage).to receive(:initial).and_return(initial)
Yast::Timezone.main
end
subject { Yast::Timezone }
describe "#ProposeLocaltime" do
subject { Yast::Timezone.ProposeLocaltime }
it "returns true if a Windows partition is found" do
Yast::Timezone.windows_partition = true
allow(Yast::SCR).to receive(:Read)
.with(path(".probe.is_vmware")).and_return(false)
expect(subject).to eq(true)
Yast::Timezone.windows_partition = false
end
it "returns true if running in VMware VM" do
expect(Yast::SCR).to receive(:Read)
.with(path(".probe.is_vmware")).and_return(true)
expect(subject).to eq(true)
end
it "returns true if running in on a 32bit Mac" do
allow(Yast::SCR).to receive(:Read)
.with(path(".probe.is_vmware")).and_return(false)
expect(Yast::Arch).to receive(:ppc32).and_return(true)
expect(Yast::Arch).to receive(:board_mac).and_return(true)
expect(subject).to eq(true)
end
it "returns false otherwise" do
allow(Yast::SCR).to receive(:Read)
.with(path(".probe.is_vmware")).and_return(false)
expect(Yast::Arch).to receive(:board_mac).and_return(false)
expect(subject).to eq(false)
end
end
describe "#timezone" do
context "when timezone is read-only during installation" do
let(:readonly_timezone) { true }
let(:initial) { true }
it "returns 'UTC'" do
expect(subject.timezone).to eq("UTC")
end
context "and default timezone is set" do
let(:default_timezone) { "Atlantic/Canary" }
it "returns the default timezone" do
expect(subject.timezone).to eq("Atlantic/Canary")
end
end
end
end
describe "#Set" do
context "when timezone is read-only during installation" do
let(:readonly_timezone) { true }
let(:initial) { true }
it "returns -1" do
expect(subject.Set("Atlantic/Canary", true)).to eq(-1)
end
it "does not modify the timezone" do
subject.Set("Atlantic/Canary", true)
expect(subject.timezone).to eq("UTC")
end
end
end
describe "#readonly" do
context "when timezone is read-only" do
let(:readonly_timezone) { true }
it "returns true" do
expect(subject.readonly).to eq(true)
end
end
context "when timezone is not read-only" do
let(:readonly_timezone) { false }
it "returns false" do
expect(subject.readonly).to eq(false)
end
end
end
end