crowbar-client 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +6 -0
- data/LICENSE +202 -0
- data/README.md +49 -0
- data/bin/crowbar +37 -0
- data/lib/crowbar-client.rb +17 -0
- data/lib/crowbar/client.rb +82 -0
- data/lib/crowbar/client/app.rb +60 -0
- data/lib/crowbar/client/app/barclamp.rb +77 -0
- data/lib/crowbar/client/app/base.rb +97 -0
- data/lib/crowbar/client/app/batch.rb +100 -0
- data/lib/crowbar/client/app/entry.rb +121 -0
- data/lib/crowbar/client/app/host_ip.rb +65 -0
- data/lib/crowbar/client/app/interface.rb +63 -0
- data/lib/crowbar/client/app/network.rb +35 -0
- data/lib/crowbar/client/app/node.rb +451 -0
- data/lib/crowbar/client/app/proposal.rb +300 -0
- data/lib/crowbar/client/app/repository.rb +149 -0
- data/lib/crowbar/client/app/reset.rb +58 -0
- data/lib/crowbar/client/app/role.rb +140 -0
- data/lib/crowbar/client/app/virtual_ip.rb +65 -0
- data/lib/crowbar/client/command.rb +54 -0
- data/lib/crowbar/client/command/barclamp.rb +26 -0
- data/lib/crowbar/client/command/barclamp/list.rb +64 -0
- data/lib/crowbar/client/command/base.rb +55 -0
- data/lib/crowbar/client/command/batch.rb +29 -0
- data/lib/crowbar/client/command/batch/build.rb +36 -0
- data/lib/crowbar/client/command/batch/export.rb +36 -0
- data/lib/crowbar/client/command/host_ip.rb +29 -0
- data/lib/crowbar/client/command/host_ip/allocate.rb +50 -0
- data/lib/crowbar/client/command/host_ip/deallocate.rb +42 -0
- data/lib/crowbar/client/command/interface.rb +29 -0
- data/lib/crowbar/client/command/interface/disable.rb +42 -0
- data/lib/crowbar/client/command/interface/enable.rb +50 -0
- data/lib/crowbar/client/command/node.rb +74 -0
- data/lib/crowbar/client/command/node/allocate.rb +48 -0
- data/lib/crowbar/client/command/node/delete.rb +44 -0
- data/lib/crowbar/client/command/node/hardware.rb +48 -0
- data/lib/crowbar/client/command/node/identify.rb +48 -0
- data/lib/crowbar/client/command/node/list.rb +71 -0
- data/lib/crowbar/client/command/node/powercycle.rb +48 -0
- data/lib/crowbar/client/command/node/poweroff.rb +48 -0
- data/lib/crowbar/client/command/node/poweron.rb +48 -0
- data/lib/crowbar/client/command/node/reboot.rb +48 -0
- data/lib/crowbar/client/command/node/reinstall.rb +48 -0
- data/lib/crowbar/client/command/node/rename.rb +44 -0
- data/lib/crowbar/client/command/node/reset.rb +48 -0
- data/lib/crowbar/client/command/node/role.rb +44 -0
- data/lib/crowbar/client/command/node/show.rb +67 -0
- data/lib/crowbar/client/command/node/shutdown.rb +48 -0
- data/lib/crowbar/client/command/node/status.rb +71 -0
- data/lib/crowbar/client/command/node/transition.rb +44 -0
- data/lib/crowbar/client/command/proposal.rb +44 -0
- data/lib/crowbar/client/command/proposal/commit.rb +50 -0
- data/lib/crowbar/client/command/proposal/create.rb +130 -0
- data/lib/crowbar/client/command/proposal/delete.rb +48 -0
- data/lib/crowbar/client/command/proposal/dequeue.rb +48 -0
- data/lib/crowbar/client/command/proposal/edit.rb +129 -0
- data/lib/crowbar/client/command/proposal/list.rb +68 -0
- data/lib/crowbar/client/command/proposal/show.rb +71 -0
- data/lib/crowbar/client/command/repository.rb +38 -0
- data/lib/crowbar/client/command/repository/activate.rb +44 -0
- data/lib/crowbar/client/command/repository/activate_all.rb +42 -0
- data/lib/crowbar/client/command/repository/deactivate.rb +44 -0
- data/lib/crowbar/client/command/repository/deactivate_all.rb +42 -0
- data/lib/crowbar/client/command/repository/list.rb +71 -0
- data/lib/crowbar/client/command/reset.rb +29 -0
- data/lib/crowbar/client/command/reset/nodes.rb +36 -0
- data/lib/crowbar/client/command/reset/proposal.rb +36 -0
- data/lib/crowbar/client/command/role.rb +29 -0
- data/lib/crowbar/client/command/role/list.rb +70 -0
- data/lib/crowbar/client/command/role/show.rb +70 -0
- data/lib/crowbar/client/command/virtual_ip.rb +29 -0
- data/lib/crowbar/client/command/virtual_ip/allocate.rb +50 -0
- data/lib/crowbar/client/command/virtual_ip/deallocate.rb +42 -0
- data/lib/crowbar/client/config.rb +178 -0
- data/lib/crowbar/client/filter.rb +33 -0
- data/lib/crowbar/client/filter/array.rb +29 -0
- data/lib/crowbar/client/filter/base.rb +41 -0
- data/lib/crowbar/client/filter/hash.rb +33 -0
- data/lib/crowbar/client/filter/subset.rb +45 -0
- data/lib/crowbar/client/formatter.rb +33 -0
- data/lib/crowbar/client/formatter/array.rb +49 -0
- data/lib/crowbar/client/formatter/base.rb +47 -0
- data/lib/crowbar/client/formatter/hash.rb +51 -0
- data/lib/crowbar/client/formatter/nested.rb +134 -0
- data/lib/crowbar/client/mixin.rb +30 -0
- data/lib/crowbar/client/mixin/barclamp.rb +41 -0
- data/lib/crowbar/client/mixin/filter.rb +33 -0
- data/lib/crowbar/client/mixin/format.rb +56 -0
- data/lib/crowbar/client/request.rb +57 -0
- data/lib/crowbar/client/request/barclamp.rb +26 -0
- data/lib/crowbar/client/request/barclamp/list.rb +35 -0
- data/lib/crowbar/client/request/base.rb +71 -0
- data/lib/crowbar/client/request/batch.rb +29 -0
- data/lib/crowbar/client/request/batch/build.rb +33 -0
- data/lib/crowbar/client/request/batch/export.rb +33 -0
- data/lib/crowbar/client/request/host_ip.rb +29 -0
- data/lib/crowbar/client/request/host_ip/allocate.rb +50 -0
- data/lib/crowbar/client/request/host_ip/deallocate.rb +48 -0
- data/lib/crowbar/client/request/interface.rb +29 -0
- data/lib/crowbar/client/request/interface/disable.rb +48 -0
- data/lib/crowbar/client/request/interface/enable.rb +48 -0
- data/lib/crowbar/client/request/node.rb +47 -0
- data/lib/crowbar/client/request/node/action.rb +39 -0
- data/lib/crowbar/client/request/node/delete.rb +38 -0
- data/lib/crowbar/client/request/node/list.rb +37 -0
- data/lib/crowbar/client/request/node/rename.rb +47 -0
- data/lib/crowbar/client/request/node/role.rb +47 -0
- data/lib/crowbar/client/request/node/show.rb +38 -0
- data/lib/crowbar/client/request/node/status.rb +36 -0
- data/lib/crowbar/client/request/node/transition.rb +48 -0
- data/lib/crowbar/client/request/party.rb +79 -0
- data/lib/crowbar/client/request/proposal.rb +47 -0
- data/lib/crowbar/client/request/proposal/commit.rb +40 -0
- data/lib/crowbar/client/request/proposal/create.rb +46 -0
- data/lib/crowbar/client/request/proposal/delete.rb +39 -0
- data/lib/crowbar/client/request/proposal/dequeue.rb +40 -0
- data/lib/crowbar/client/request/proposal/edit.rb +47 -0
- data/lib/crowbar/client/request/proposal/list.rb +38 -0
- data/lib/crowbar/client/request/proposal/show.rb +39 -0
- data/lib/crowbar/client/request/proposal/template.rb +39 -0
- data/lib/crowbar/client/request/repository.rb +38 -0
- data/lib/crowbar/client/request/repository/activate.rb +46 -0
- data/lib/crowbar/client/request/repository/activate_all.rb +37 -0
- data/lib/crowbar/client/request/repository/deactivate.rb +46 -0
- data/lib/crowbar/client/request/repository/deactivate_all.rb +37 -0
- data/lib/crowbar/client/request/repository/list.rb +36 -0
- data/lib/crowbar/client/request/reset.rb +29 -0
- data/lib/crowbar/client/request/reset/nodes.rb +33 -0
- data/lib/crowbar/client/request/reset/proposal.rb +33 -0
- data/lib/crowbar/client/request/role.rb +29 -0
- data/lib/crowbar/client/request/role/list.rb +38 -0
- data/lib/crowbar/client/request/role/show.rb +39 -0
- data/lib/crowbar/client/request/virtual_ip.rb +29 -0
- data/lib/crowbar/client/request/virtual_ip/allocate.rb +50 -0
- data/lib/crowbar/client/request/virtual_ip/deallocate.rb +48 -0
- data/lib/crowbar/client/util.rb +27 -0
- data/lib/crowbar/client/util/editor.rb +107 -0
- data/lib/crowbar/client/util/runner.rb +77 -0
- data/lib/crowbar/client/version.rb +33 -0
- data/spec/crowbar/client/app_spec.rb +21 -0
- data/spec/crowbar/client/command/barclamp/list_spec.rb +39 -0
- data/spec/crowbar/client/command/batch/build_spec.rb +39 -0
- data/spec/crowbar/client/command/batch/export_spec.rb +39 -0
- data/spec/crowbar/client/command/host_ip/allocate_spec.rb +39 -0
- data/spec/crowbar/client/command/host_ip/deallocate_spec.rb +39 -0
- data/spec/crowbar/client/command/interface/disable_spec.rb +39 -0
- data/spec/crowbar/client/command/interface/enable_spec.rb +39 -0
- data/spec/crowbar/client/command/node/allocate_spec.rb +39 -0
- data/spec/crowbar/client/command/node/delete_spec.rb +39 -0
- data/spec/crowbar/client/command/node/hardware_spec.rb +39 -0
- data/spec/crowbar/client/command/node/identify_spec.rb +39 -0
- data/spec/crowbar/client/command/node/list_spec.rb +39 -0
- data/spec/crowbar/client/command/node/powercycle_spec.rb +39 -0
- data/spec/crowbar/client/command/node/poweroff_spec.rb +39 -0
- data/spec/crowbar/client/command/node/poweron_spec.rb +39 -0
- data/spec/crowbar/client/command/node/reboot_spec.rb +39 -0
- data/spec/crowbar/client/command/node/reinstall_spec.rb +39 -0
- data/spec/crowbar/client/command/node/rename_spec.rb +39 -0
- data/spec/crowbar/client/command/node/reset_spec.rb +39 -0
- data/spec/crowbar/client/command/node/role_spec.rb +39 -0
- data/spec/crowbar/client/command/node/show_spec.rb +39 -0
- data/spec/crowbar/client/command/node/shutdown_spec.rb +39 -0
- data/spec/crowbar/client/command/node/status_spec.rb +39 -0
- data/spec/crowbar/client/command/node/transition_spec.rb +39 -0
- data/spec/crowbar/client/command/proposal/commit_spec.rb +39 -0
- data/spec/crowbar/client/command/proposal/create_spec.rb +61 -0
- data/spec/crowbar/client/command/proposal/delete_spec.rb +39 -0
- data/spec/crowbar/client/command/proposal/dequeue_spec.rb +39 -0
- data/spec/crowbar/client/command/proposal/edit_spec.rb +62 -0
- data/spec/crowbar/client/command/proposal/list_spec.rb +39 -0
- data/spec/crowbar/client/command/proposal/show_spec.rb +39 -0
- data/spec/crowbar/client/command/repository/activate_all_spec.rb +39 -0
- data/spec/crowbar/client/command/repository/activate_spec.rb +39 -0
- data/spec/crowbar/client/command/repository/deactivate_all_spec.rb +39 -0
- data/spec/crowbar/client/command/repository/deactivate_spec.rb +39 -0
- data/spec/crowbar/client/command/repository/list_spec.rb +39 -0
- data/spec/crowbar/client/command/reset/nodes_spec.rb +39 -0
- data/spec/crowbar/client/command/reset/proposal_spec.rb +39 -0
- data/spec/crowbar/client/command/role/list_spec.rb +39 -0
- data/spec/crowbar/client/command/role/show_spec.rb +39 -0
- data/spec/crowbar/client/command/virtual_ip/allocate_spec.rb +39 -0
- data/spec/crowbar/client/command/virtual_ip/deallocate_spec.rb +39 -0
- data/spec/crowbar/client/filter/array_spec.rb +65 -0
- data/spec/crowbar/client/filter/hash_spec.rb +65 -0
- data/spec/crowbar/client/filter/subset_spec.rb +77 -0
- data/spec/crowbar/client/formatter/array_spec.rb +102 -0
- data/spec/crowbar/client/formatter/hash_spec.rb +108 -0
- data/spec/crowbar/client/formatter/nested_spec.rb +106 -0
- data/spec/crowbar/client/request/barclamp/list_spec.rb +50 -0
- data/spec/crowbar/client/request/batch/build_spec.rb +64 -0
- data/spec/crowbar/client/request/batch/export_spec.rb +64 -0
- data/spec/crowbar/client/request/host_ip/allocate_spec.rb +61 -0
- data/spec/crowbar/client/request/host_ip/deallocate_spec.rb +57 -0
- data/spec/crowbar/client/request/interface/disable_spec.rb +57 -0
- data/spec/crowbar/client/request/interface/enable_spec.rb +57 -0
- data/spec/crowbar/client/request/node/action_spec.rb +53 -0
- data/spec/crowbar/client/request/node/delete_spec.rb +52 -0
- data/spec/crowbar/client/request/node/list_spec.rb +50 -0
- data/spec/crowbar/client/request/node/rename_spec.rb +55 -0
- data/spec/crowbar/client/request/node/role_spec.rb +55 -0
- data/spec/crowbar/client/request/node/show_spec.rb +52 -0
- data/spec/crowbar/client/request/node/status_spec.rb +50 -0
- data/spec/crowbar/client/request/node/transition_spec.rb +56 -0
- data/spec/crowbar/client/request/party_spec.rb +24 -0
- data/spec/crowbar/client/request/proposal/commit_spec.rb +53 -0
- data/spec/crowbar/client/request/proposal/create_spec.rb +56 -0
- data/spec/crowbar/client/request/proposal/delete_spec.rb +53 -0
- data/spec/crowbar/client/request/proposal/dequeue_spec.rb +53 -0
- data/spec/crowbar/client/request/proposal/edit_spec.rb +56 -0
- data/spec/crowbar/client/request/proposal/list_spec.rb +52 -0
- data/spec/crowbar/client/request/proposal/show_spec.rb +53 -0
- data/spec/crowbar/client/request/proposal/template_spec.rb +52 -0
- data/spec/crowbar/client/request/repository/activate_all_spec.rb +50 -0
- data/spec/crowbar/client/request/repository/activate_spec.rb +56 -0
- data/spec/crowbar/client/request/repository/deactivate_all_spec.rb +50 -0
- data/spec/crowbar/client/request/repository/deactivate_spec.rb +56 -0
- data/spec/crowbar/client/request/repository/list_spec.rb +50 -0
- data/spec/crowbar/client/request/reset/nodes_spec.rb +55 -0
- data/spec/crowbar/client/request/reset/proposal_spec.rb +55 -0
- data/spec/crowbar/client/request/role/list_spec.rb +52 -0
- data/spec/crowbar/client/request/role/show_spec.rb +53 -0
- data/spec/crowbar/client/request/virtual_ip/allocate_spec.rb +61 -0
- data/spec/crowbar/client/request/virtual_ip/deallocate_spec.rb +57 -0
- data/spec/crowbar/client/util/editor_spec.rb +108 -0
- data/spec/crowbar/client/util/runner_spec.rb +24 -0
- data/spec/crowbar/client_spec.rb +21 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/support/command_context.rb +37 -0
- data/spec/support/request_examples.rb +55 -0
- metadata +549 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2015, SUSE Linux GmbH
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require_relative "../../../spec_helper"
|
|
18
|
+
|
|
19
|
+
describe "Crowbar::Client::Filter::Subset" do
|
|
20
|
+
subject { ::Crowbar::Client::Filter::Subset }
|
|
21
|
+
|
|
22
|
+
let!(:values) do
|
|
23
|
+
{
|
|
24
|
+
id: "herbert",
|
|
25
|
+
name: "Herbert",
|
|
26
|
+
foo: {
|
|
27
|
+
bar: {
|
|
28
|
+
baz: "Hello"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
children: [
|
|
32
|
+
{
|
|
33
|
+
name: "Hans"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "Olga"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context "with a defined filter" do
|
|
43
|
+
it "limits the hash output" do
|
|
44
|
+
instance = subject.new(
|
|
45
|
+
values: values,
|
|
46
|
+
filter: "foo.bar"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
expect(
|
|
50
|
+
instance.result
|
|
51
|
+
).to eq(values[:foo][:bar])
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "returns a nil value" do
|
|
55
|
+
instance = subject.new(
|
|
56
|
+
values: values,
|
|
57
|
+
filter: "nothing"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
expect(
|
|
61
|
+
instance.result
|
|
62
|
+
).to eq(nil)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context "without defined filter" do
|
|
67
|
+
it "returns unfiltered values" do
|
|
68
|
+
instance = subject.new(
|
|
69
|
+
values: values
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
expect(
|
|
73
|
+
instance.result
|
|
74
|
+
).to eq(values)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2015, SUSE Linux GmbH
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require_relative "../../../spec_helper"
|
|
18
|
+
|
|
19
|
+
describe "Crowbar::Client::Formatter::Array" do
|
|
20
|
+
subject { ::Crowbar::Client::Formatter::Array }
|
|
21
|
+
|
|
22
|
+
let!(:values) do
|
|
23
|
+
[
|
|
24
|
+
"row1",
|
|
25
|
+
"row2",
|
|
26
|
+
"row3"
|
|
27
|
+
]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "with table format" do
|
|
31
|
+
let!(:headings) do
|
|
32
|
+
[
|
|
33
|
+
"Row"
|
|
34
|
+
]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
let!(:instance) do
|
|
38
|
+
subject.new(
|
|
39
|
+
format: :table,
|
|
40
|
+
values: values,
|
|
41
|
+
headings: headings
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "returns a terminal table instance" do
|
|
46
|
+
expect(instance.result).to(
|
|
47
|
+
be_kind_of(Terminal::Table)
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "with plain format" do
|
|
53
|
+
let!(:instance) do
|
|
54
|
+
subject.new(
|
|
55
|
+
format: :plain,
|
|
56
|
+
values: values
|
|
57
|
+
)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "returns a plain list" do
|
|
61
|
+
result = <<-EOF.strip_heredoc.strip
|
|
62
|
+
row1
|
|
63
|
+
row2
|
|
64
|
+
row3
|
|
65
|
+
EOF
|
|
66
|
+
|
|
67
|
+
expect(instance.result).to(
|
|
68
|
+
eq(result)
|
|
69
|
+
)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
context "with json format" do
|
|
74
|
+
let!(:instance) do
|
|
75
|
+
subject.new(
|
|
76
|
+
format: :json,
|
|
77
|
+
values: values
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "returns valid json" do
|
|
82
|
+
expect(instance.result).to(
|
|
83
|
+
eq(JSON.pretty_generate(values))
|
|
84
|
+
)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
context "with invalid format" do
|
|
89
|
+
it "raises an invalid format error" do
|
|
90
|
+
instance = subject.new(
|
|
91
|
+
format: :foo,
|
|
92
|
+
values: values
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
expect do
|
|
96
|
+
instance.result
|
|
97
|
+
end.to(
|
|
98
|
+
raise_error(Crowbar::Client::InvalidFormatError)
|
|
99
|
+
)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2015, SUSE Linux GmbH
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require_relative "../../../spec_helper"
|
|
18
|
+
|
|
19
|
+
describe "Crowbar::Client::Formatter::Hash" do
|
|
20
|
+
subject { ::Crowbar::Client::Formatter::Hash }
|
|
21
|
+
|
|
22
|
+
let!(:values) do
|
|
23
|
+
[
|
|
24
|
+
{
|
|
25
|
+
foo: "Hello1",
|
|
26
|
+
bar: "Hello2",
|
|
27
|
+
baz: "Hello3"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
foo: "Foo",
|
|
31
|
+
bar: "Bar",
|
|
32
|
+
baz: "Baz"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context "with table format" do
|
|
38
|
+
let!(:headings) do
|
|
39
|
+
[
|
|
40
|
+
"Row"
|
|
41
|
+
]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
let!(:instance) do
|
|
45
|
+
subject.new(
|
|
46
|
+
format: :table,
|
|
47
|
+
values: values,
|
|
48
|
+
headings: headings
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "returns a terminal table instance" do
|
|
53
|
+
expect(instance.result).to(
|
|
54
|
+
be_kind_of(Terminal::Table)
|
|
55
|
+
)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context "with plain format" do
|
|
60
|
+
let!(:instance) do
|
|
61
|
+
subject.new(
|
|
62
|
+
format: :plain,
|
|
63
|
+
values: values
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "returns a plain list" do
|
|
68
|
+
result = <<-EOF.strip_heredoc.strip
|
|
69
|
+
Hello1 Hello2 Hello3
|
|
70
|
+
Foo Bar Baz
|
|
71
|
+
EOF
|
|
72
|
+
|
|
73
|
+
expect(instance.result).to(
|
|
74
|
+
eq(result)
|
|
75
|
+
)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context "with json format" do
|
|
80
|
+
let!(:instance) do
|
|
81
|
+
subject.new(
|
|
82
|
+
format: :json,
|
|
83
|
+
values: values
|
|
84
|
+
)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "returns valid json" do
|
|
88
|
+
expect(instance.result).to(
|
|
89
|
+
eq(JSON.pretty_generate(values))
|
|
90
|
+
)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
context "with invalid format" do
|
|
95
|
+
it "raises an invalid format error" do
|
|
96
|
+
instance = subject.new(
|
|
97
|
+
format: :foo,
|
|
98
|
+
values: values
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
expect do
|
|
102
|
+
instance.result
|
|
103
|
+
end.to(
|
|
104
|
+
raise_error(Crowbar::Client::InvalidFormatError)
|
|
105
|
+
)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2015, SUSE Linux GmbH
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require_relative "../../../spec_helper"
|
|
18
|
+
|
|
19
|
+
describe "Crowbar::Client::Formatter::Nested" do
|
|
20
|
+
subject { ::Crowbar::Client::Formatter::Nested }
|
|
21
|
+
|
|
22
|
+
let!(:values) do
|
|
23
|
+
{
|
|
24
|
+
foo: "Hello1",
|
|
25
|
+
bar: "Hello2",
|
|
26
|
+
baz: "Hello3",
|
|
27
|
+
children: {
|
|
28
|
+
foo: "Works"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "with table format" do
|
|
34
|
+
let!(:headings) do
|
|
35
|
+
[
|
|
36
|
+
"Row"
|
|
37
|
+
]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
let!(:instance) do
|
|
41
|
+
subject.new(
|
|
42
|
+
format: :table,
|
|
43
|
+
values: values,
|
|
44
|
+
headings: headings
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "returns a terminal table instance" do
|
|
49
|
+
expect(instance.result).to(
|
|
50
|
+
be_kind_of(Terminal::Table)
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context "with plain format" do
|
|
56
|
+
let!(:instance) do
|
|
57
|
+
subject.new(
|
|
58
|
+
format: :plain,
|
|
59
|
+
values: values
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "returns a plain list" do
|
|
64
|
+
result = <<-EOF.strip_heredoc.strip
|
|
65
|
+
foo Hello1
|
|
66
|
+
bar Hello2
|
|
67
|
+
baz Hello3
|
|
68
|
+
children.foo Works
|
|
69
|
+
EOF
|
|
70
|
+
|
|
71
|
+
expect(instance.result).to(
|
|
72
|
+
eq(result)
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
context "with json format" do
|
|
78
|
+
let!(:instance) do
|
|
79
|
+
subject.new(
|
|
80
|
+
format: :json,
|
|
81
|
+
values: values
|
|
82
|
+
)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "returns valid json" do
|
|
86
|
+
expect(instance.result).to(
|
|
87
|
+
eq(JSON.pretty_generate(values))
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context "with invalid format" do
|
|
93
|
+
it "raises an invalid format error" do
|
|
94
|
+
instance = subject.new(
|
|
95
|
+
format: :foo,
|
|
96
|
+
values: values
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
expect do
|
|
100
|
+
instance.result
|
|
101
|
+
end.to(
|
|
102
|
+
raise_error(Crowbar::Client::InvalidFormatError)
|
|
103
|
+
)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2015, SUSE Linux GmbH
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
require_relative "../../../../spec_helper"
|
|
18
|
+
|
|
19
|
+
describe "Crowbar::Client::Request::Barclamp::List" do
|
|
20
|
+
it_behaves_like "a request class" do
|
|
21
|
+
subject do
|
|
22
|
+
::Crowbar::Client::Request::Barclamp::List.new(
|
|
23
|
+
attrs
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
let!(:attrs) do
|
|
28
|
+
{}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
let!(:params) do
|
|
32
|
+
{}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
let!(:method) do
|
|
36
|
+
:get
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
let!(:url) do
|
|
40
|
+
"crowbar"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
let!(:headers) do
|
|
44
|
+
{
|
|
45
|
+
"Content-Type" => "application/json",
|
|
46
|
+
"Accept" => "application/json"
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|