Skip to content

Commit

Permalink
missing specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mensfeld committed May 21, 2024
1 parent a48dd72 commit 9f8ac21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/karafka/web/contracts/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Config < Web::Contracts::Base

required(:cache) { |val| !val.nil? }
required(:per_page) { |val| val.is_a?(Integer) && val >= 1 && val <= 100 }
required(:max_visible_payload_size) { |val| val.is_a?(Integer) && val >= 1 }

required(:dlq_patterns) do |val|
val.is_a?(Array) &&
Expand Down
15 changes: 14 additions & 1 deletion spec/lib/karafka/web/contracts/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
},
cache: Object.new,
per_page: 50,
dlq_patterns: []
dlq_patterns: [],
max_visible_payload_size: 100
}
}
end
Expand Down Expand Up @@ -206,6 +207,18 @@
it { expect(contract.call(params)).not_to be_success }
end

context 'when max_visible_payload_size is not an integer' do
before { params[:ui][:max_visible_payload_size] = '1' }

it { expect(contract.call(params)).not_to be_success }
end

context 'when max_visible_payload_size is less than 1' do
before { params[:ui][:max_visible_payload_size] = 0 }

it { expect(contract.call(params)).not_to be_success }
end

context 'when dlq_patterns is not an array' do
before { params[:ui][:dlq_patterns] = '1' }

Expand Down

0 comments on commit 9f8ac21

Please sign in to comment.