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

linux – 如何使用serverspec测试文件缺失?,第1张

概述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.

总结

以上是内存溢出为你收集整理的linux – 如何使用serverspec测试文件缺失?全部内容,希望文章能够帮你解决linux – 如何使用serverspec测试文件缺失?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1038295.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存