加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 如何使用serverspec测试文件缺失?

发布时间:2020-12-13 16:36:08 所属栏目:Linux 来源:网络整理
导读:serverspec guide on resource types没有解释如何测试文件的缺失,而不是它的存在.这是我能想到的最好的: describe command('/bin/bash -c "[[ ! -e /var/foo ]]"') do its(:exit_status) { should eq 0 }end 这似乎非常笨重,但比leveraging the builtins更
serverspec guide on resource types没有解释如何测试文件的缺失,而不是它的存在.这是我能想到的最好的:
describe command('/bin/bash -c "[[ ! -e /var/foo ]]"') do
  its(:exit_status) { should eq 0 }
end

这似乎非常笨重,但比leveraging the builtins更好:

describe file('/var/foo') do
  it { should_not be_file }
  it { should_not be_directory }
  it { should_not be_socket }
  it { should_not be_symlink }
end

有一个更好的方法吗?

解决方法

serverspec文件对象现在响应.exists ?,所以这适用:
describe file('/var/foo') do
  it { should_not exist }
end

serverspec v2.17.0中的功能was added.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读