Commit c7532efe authored by Jamie Tanna's avatar Jamie Tanna

Allow us to specify the user's group

Let's make the group configurable too.
parent 26b32e27
Pipeline #8517366 passed with stage
in 1 minute and 38 seconds
......@@ -19,4 +19,5 @@
user "create user #{node['user']}" do
username node['user']
group node['group']
end
......@@ -35,6 +35,7 @@ describe 'user-cookbook::default' do
it 'creates the jamie user' do
expect(chef_run).to create_user('create user jamie')
.with(username: 'jamie')
.with(group: nil)
end
end
......@@ -53,6 +54,27 @@ describe 'user-cookbook::default' do
it 'creates the test user' do
expect(chef_run).to create_user('create user test')
.with(username: 'test')
.with(group: nil)
end
end
context 'When the user and group attributes are set' do
let(:chef_run) do
runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node|
node.automatic['user'] = 'test'
node.automatic['group'] = 'users'
end
runner.converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
it 'creates the test user' do
expect(chef_run).to create_user('create user test')
.with(username: 'test')
.with(group: 'users')
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment