-
Notifications
You must be signed in to change notification settings - Fork 44
/
ssh_importer_presenter_test.rb
executable file
·86 lines (69 loc) · 2.44 KB
/
ssh_importer_presenter_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
#!/usr/bin/env rspec
require_relative "test_helper"
require "installation/ssh_importer_presenter"
require "installation/ssh_importer"
describe ::Installation::SshImporterPresenter do
Yast.import "Mode"
let(:importer) { ::Installation::SshImporter.instance }
let(:presenter) { described_class.new(importer) }
describe "#summary" do
let(:mode) { "installation" }
let(:device) { "dev" }
let(:copy_config) { false }
before do
textdomain "installation"
importer.configurations.clear
importer.reset
importer.add_config(FIXTURES_DIR.join(config), "dev")
importer.device = device
importer.copy_config = copy_config
allow(Yast::Mode).to receive(:mode).and_return(mode)
end
context "when no previous configurations were found" do
let(:config) { "root3" }
let(:device) { nil }
context "and mode is installation" do
let(:mode) { "installation" }
let(:message) { _("No previous Linux installation found") }
it "returns 'No previous Linux...' message" do
expect(presenter.summary).to include(message)
end
end
context "and mode is autoinstallation" do
let(:mode) { "autoinstallation" }
let(:message) { _("No previous Linux installation found") }
it "returns 'No previous Linux...' message" do
expect(presenter.summary).to include(message)
end
end
context "and mode is not installation or autoinstallation" do
let(:mode) { "normal" }
let(:message) { _("No existing SSH host keys will be copied") }
it "returns 'No previous Linux...' message" do
expect(presenter.summary).to include(message)
end
end
end
context "when device is set and copy config is enabled" do
let(:config) { "root1" }
let(:copy_config) { true }
let(:message) do
_("SSH host keys and configuration will be copied from %s") %
"Operating system 1"
end
it "returns 'SSH host keys and configuration...'" do
expect(presenter.summary).to include(message)
end
end
context "when device is set and copy config is disabled" do
let(:config) { "root1" }
let(:message) do
_("SSH host keys will be copied from %s") %
"Operating system 1"
end
it "returns 'SSH host keys will be copied...'" do
expect(presenter.summary).to include(message)
end
end
end
end