Skip to content

Commit d67bb0b

Browse files
committed
Add more potential edge cases
1 parent 99d9f24 commit d67bb0b

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

spec/octocatalog-diff/tests/catalog-diff/filter/single_item_array_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,55 @@
6969
result = subject.filtered?(diff_obj)
7070
expect(result).to eq(false)
7171
end
72+
73+
it 'should not filter when both of the items are arrays' do
74+
diff = [
75+
'~',
76+
"File\ffoobar.json",
77+
{ 'parameters' => { 'notify' => ['Service[bar]'] } },
78+
{ 'parameters' => { 'notify' => ['Service[foo]'] } }
79+
]
80+
diff_obj = OctocatalogDiff::API::V1::Diff.new(diff)
81+
result = subject.filtered?(diff_obj)
82+
expect(result).to eq(false)
83+
end
84+
85+
it 'should not filter when both of the items are arrays even if identical' do
86+
# This diff should never be produced by the program, but catch the edge case anyway.
87+
diff = [
88+
'~',
89+
"File\ffoobar.json",
90+
{ 'parameters' => { 'notify' => ['Service[foo]'] } },
91+
{ 'parameters' => { 'notify' => ['Service[foo]'] } }
92+
]
93+
diff_obj = OctocatalogDiff::API::V1::Diff.new(diff)
94+
result = subject.filtered?(diff_obj)
95+
expect(result).to eq(false)
96+
end
97+
98+
it 'should not filter when both of the items are strings even if identical' do
99+
# This diff should never be produced by the program, but catch the edge case anyway.
100+
diff = [
101+
'~',
102+
"File\ffoobar.json",
103+
{ 'parameters' => { 'notify' => 'Service[foo]' } },
104+
{ 'parameters' => { 'notify' => 'Service[foo]' } }
105+
]
106+
diff_obj = OctocatalogDiff::API::V1::Diff.new(diff)
107+
result = subject.filtered?(diff_obj)
108+
expect(result).to eq(false)
109+
end
110+
111+
it 'should not filter when one item has an array with multiple elements' do
112+
diff = [
113+
'~',
114+
"File\ffoobar.json",
115+
{ 'parameters' => { 'notify' => 'Service[foo]' } },
116+
{ 'parameters' => { 'notify' => ['Service[foo]', 'Service[bar]'] } }
117+
]
118+
diff_obj = OctocatalogDiff::API::V1::Diff.new(diff)
119+
result = subject.filtered?(diff_obj)
120+
expect(result).to eq(false)
121+
end
72122
end
73123
end

0 commit comments

Comments
 (0)