Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update file.md with example how to test symlinked files #1555

Merged
merged 1 commit into from
Mar 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/resources/file.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,25 @@ The following example shows how to use the `file` audit resource to verify if th
describe command('pgrep ntp') do
its('exit_status') { should eq 0 }
end

### Test parameters of symlinked file

If you need to test the parameters of the target file for a symlink, you can use the `link_path` method for the `file` resource.

For example, for the following symlink:

lrwxrwxrwx. 1 root root 11 03-10 17:56 /dev/virtio-ports/com.redhat.rhevm.vdsm -> ../vport2p1

... you can write controls for both the link and the target.

describe file('/dev/virtio-ports/com.redhat.rhevm.vdsm') do
it { should be_symlink }
end

virito_port_vdsm = file('/dev/virtio-ports/com.redhat.rhevm.vdsm').link_path
describe file(virito_port_vdsm) do
it { should exist }
it { should be_character_device }
it { should be_owned_by 'ovirtagent' }
it { should be_grouped_into 'ovirtagent' }
end