Skip to content

Commit 90fcf4e

Browse files
Test: Add unit tests for order-independent binding comparison
Add comprehensive unit tests to validate the new set-based binding comparison logic in iis_site type. Tests verify that: - Bindings with identical content but different order are in sync - Bindings with different content are correctly detected as out of sync - Bindings with different counts are properly identified as out of sync These tests ensure the order-independent comparison works correctly and prevent regression to order-sensitive behavior.
1 parent de5926e commit 90fcf4e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

spec/unit/puppet/type/iis_site_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,40 @@
137137
'bindinginformation' => '*:80:'
138138
}
139139
end
140+
141+
context 'order independent comparison' do
142+
let(:bindings_property) { resource.property(:bindings) }
143+
144+
before(:each) do
145+
resource[:bindings] = [
146+
{ 'protocol' => 'http', 'bindinginformation' => '*:80:' },
147+
{ 'protocol' => 'net.msmq', 'bindinginformation' => 'hostname' },
148+
]
149+
end
150+
151+
it 'considers same bindings in different order as in sync' do
152+
current_bindings = [
153+
{ 'protocol' => 'net.msmq', 'bindinginformation' => 'hostname' },
154+
{ 'protocol' => 'http', 'bindinginformation' => '*:80:' },
155+
]
156+
expect(bindings_property.insync?(current_bindings)).to be true
157+
end
158+
159+
it 'considers different bindings as out of sync' do
160+
current_bindings = [
161+
{ 'protocol' => 'net.msmq', 'bindinginformation' => 'hostname' },
162+
{ 'protocol' => 'http', 'bindinginformation' => '*:8080:' },
163+
]
164+
expect(bindings_property.insync?(current_bindings)).to be false
165+
end
166+
167+
it 'considers different number of bindings as out of sync' do
168+
current_bindings = [
169+
{ 'protocol' => 'http', 'bindinginformation' => '*:80:' },
170+
]
171+
expect(bindings_property.insync?(current_bindings)).to be false
172+
end
173+
end
140174
end
141175

142176
context 'property :limits' do

0 commit comments

Comments
 (0)