Skip to content

Commit f33d503

Browse files
dafyddcrosbymeta-codesync[bot]
authored andcommitted
Add ChefSpec tests for packages recipe
Summary: Add spec coverage for the packages recipe which manages logrotate and pigz package installation. Tests verify the package upgrade behavior based on the manage_packages attribute. Differential Revision: D88485611 fbshipit-source-id: 81a5903308899bb37f0912a8187e26f05cdc3a85
1 parent 1f2021b commit f33d503

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (c) 2025-present, Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
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+
require './spec/spec_helper'
17+
18+
recipe 'fb_logrotate::packages', :unsupported => [:mac_os_x] do |tc|
19+
let(:chef_run) do
20+
tc.chef_run
21+
end
22+
23+
context 'when manage_packages is true' do
24+
it 'upgrades logrotate and pigz packages' do
25+
chef_run.converge(described_recipe) do |node|
26+
node.default['fb_logrotate']['manage_packages'] = true
27+
end
28+
expect(chef_run).to upgrade_package(%w{logrotate pigz})
29+
end
30+
end
31+
32+
context 'when manage_packages is false' do
33+
it 'does not upgrade logrotate and pigz packages' do
34+
chef_run.converge(described_recipe) do |node|
35+
node.default['fb_logrotate']['manage_packages'] = false
36+
end
37+
expect(chef_run).not_to upgrade_package(%w{logrotate pigz})
38+
end
39+
end
40+
end

0 commit comments

Comments
 (0)