小编con*_*sch的帖子

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

关于资源类型serverspec 指南没有解释如何测试文件的缺失,而不是它的存在。这是我能想到的最好的:

describe command('/bin/bash -c "[[ ! -e /var/foo ]]"') do
  its(:exit_status) { should eq 0 }
end
Run Code Online (Sandbox Code Playgroud)

这看起来非常笨拙,但比利用内置函数要好:

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
Run Code Online (Sandbox Code Playgroud)

有一个更好的方法吗?

linux automated-testing testing configuration-management

6
推荐指数
1
解决办法
3517
查看次数