Skip to content

Commit 5832a3b

Browse files
committed
Start rspec unit test for filter
1 parent 31d07a3 commit 5832a3b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../../spec_helper'
4+
require OctocatalogDiff::Spec.require_path('/api/v1/diff')
5+
require OctocatalogDiff::Spec.require_path('/catalog-diff/filter/single_item_array')
6+
7+
describe OctocatalogDiff::CatalogDiff::Filter::SingleItemArray do
8+
let(:subject) { described_class.new }
9+
10+
describe '#filtered?' do
11+
it 'should not filter out an added resource' do
12+
diff = ['+', "File\ffoobar.json", { 'parameters' => { 'content' => '{"foo":"bar"}' } }]
13+
diff_obj = OctocatalogDiff::API::V1::Diff.new(diff)
14+
result = subject.filtered?(diff_obj)
15+
expect(result).to eq(false)
16+
end
17+
18+
it 'should not filter out a removed resource' do
19+
diff = ['-', "File\ffoobar.json", { 'parameters' => { 'content' => '{"foo":"bar"}' } }]
20+
diff_obj = OctocatalogDiff::API::V1::Diff.new(diff)
21+
result = subject.filtered?(diff_obj)
22+
expect(result).to eq(false)
23+
end
24+
25+
it 'should filter when from-catalog has string and to-catalog has array with that string' do
26+
diff = [
27+
'~',
28+
"File\ffoobar.json",
29+
{ 'parameters' => { 'notify' => 'Service[foo]' } },
30+
{ 'parameters' => { 'notify' => ['Service[foo]'] } }
31+
]
32+
diff_obj = OctocatalogDiff::API::V1::Diff.new(diff)
33+
result = subject.filtered?(diff_obj)
34+
expect(result).to eq(true)
35+
end
36+
end
37+
end

0 commit comments

Comments
 (0)