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

Conversation

nvtkaszpir
Copy link
Contributor

No description provided.

@nvtkaszpir nvtkaszpir force-pushed the patch-1 branch 2 times, most recently from 52649b1 to bb87fcd Compare March 10, 2017 21:11
@adamleff
Copy link
Contributor

Hi, @nvtkaszpir! Thank you for your contribution!

I'd like to modify your contribution slightly to keep the language consistent and minial, and give a slightly more detailed example.

How does this look?

### 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

If this looks good to you, please add it to your submission and I'll be happy to review/accept!

Added detailed example why and how.
Updated with suggestions from Adam Leff.

Signed-off-by: Michał Sochoń <kaszpir@gmail.com>
@nvtkaszpir
Copy link
Contributor Author

Good idea. Updated commit.

Copy link
Contributor

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @nvtkaszpir

@adamleff adamleff merged commit bf36c0a into inspec:master Mar 15, 2017
@adamleff
Copy link
Contributor

Thanks, @nvtkaszpir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants