1

So, I am trying to add some unit test to my recipe.

Testing something that has an action is easy. But when your action is :nothing because it gets triggered by a notification then it sucks. The following block gets called with: notifies :create, 'directory[Create my directory]', :immediately

directory 'Create my directory' do
  path myPath
  mode '0755'
  owner 'me'
  group 'aGroup'
  action :nothing
  notifies :create_if_missing, 'remote_file[Download artifact]', :immediately
  notifies :run, 'execute[unpack artifact]', :immediately
end

When before the action was :create the unit test was simple

it 'Test create directory' do
    expect(chef_run).to create_directory('Create my directory')
        .with_path('myPath')
        .with_mode('0755')
        .with_owner('me')
        .with_group('aGroup')  
end

so how do you test something when it receives a notification?

Adrien
  • 55
  • 1
  • 4

1 Answers1

-1

Comment the action :nothing, make a kitchen test run and see the results. Do not forget to un-comment the line after testing.

Navarro
  • 1,284
  • 2
  • 17
  • 40