Merge pull request #1387 from jvrplmlmn/package-brew-unit-test

Unit test the 'package' resource for OSX (with brew)
This commit is contained in:
Dominik Richter 2017-01-03 12:24:46 +01:00 committed by GitHub
commit 74ed60ce5f
3 changed files with 11 additions and 0 deletions

View file

@ -158,6 +158,7 @@ class MockLoader
'dpkg -s curl' => cmd.call('dpkg-s-curl'),
'rpm -qia curl' => cmd.call('rpm-qia-curl'),
'pacman -Qi curl' => cmd.call('pacman-qi-curl'),
'brew info --json=v1 curl' => cmd.call('brew-info--json-v1-curl'),
'gem list --local -a -q ^rubocop$' => cmd.call('gem-list-local-a-q-rubocop'),
'npm ls -g --json bower' => cmd.call('npm-ls-g--json-bower'),
'pip show jinja2' => cmd.call('pip-show-jinja2'),

View file

@ -0,0 +1 @@
[{"name":"curl","full_name":"curl","desc":"Get a file from an HTTP, HTTPS or FTP server","homepage":"https://curl.haxx.se/","oldname":null,"aliases":[],"versions":{"stable":"7.52.1","bottle":true,"devel":null,"head":null},"revision":0,"version_scheme":0,"installed":[{"version":"7.52.1","used_options":[],"built_as_bottle":true,"poured_from_bottle":true}],"linked_keg":null,"pinned":false,"outdated":false,"keg_only":true,"dependencies":["openssl","pkg-config","libidn","rtmpdump","libssh2","c-ares","libmetalink","nghttp2"],"recommended_dependencies":[],"optional_dependencies":["openssl","libidn","rtmpdump","libssh2","c-ares","libmetalink","nghttp2"],"build_dependencies":["pkg-config"],"conflicts_with":[],"caveats":null,"requirements":[],"options":[{"option":"--with-libidn","description":"Build with support for Internationalized Domain Names"},{"option":"--with-rtmpdump","description":"Build with RTMP support"},{"option":"--with-libssh2","description":"Build with scp and sftp support"},{"option":"--with-c-ares","description":"Build with C-Ares async DNS support"},{"option":"--with-gssapi","description":"Build with GSSAPI/Kerberos authentication support."},{"option":"--with-libmetalink","description":"Build with libmetalink support."},{"option":"--with-nghttp2","description":"Build with HTTP/2 support (requires OpenSSL)"},{"option":"--with-openssl","description":"Build with OpenSSL instead of Secure Transport"}],"bottle":{"stable":{"rebuild":0,"cellar":":any","prefix":"/usr/local","root_url":"https://homebrew.bintray.com/bottles","files":{"sierra":{"url":"https://homebrew.bintray.com/bottles/curl-7.52.1.sierra.bottle.tar.gz","sha256":"47ae0e479cdb15bea6820f7f2d659d45e9d7a09a97a2d7f44c02b6c7a689dd9f"},"el_capitan":{"url":"https://homebrew.bintray.com/bottles/curl-7.52.1.el_capitan.bottle.tar.gz","sha256":"e296cad67c36d93cf0ce85d0b797fc442fd1c56d04523dea8afe751f54977ab2"},"yosemite":{"url":"https://homebrew.bintray.com/bottles/curl-7.52.1.yosemite.bottle.tar.gz","sha256":"36ff81fd9579b8ef4e556fd7e5ae3bf38ae016110f1563561c018163006fb3f4"}}}}}]

View file

@ -87,6 +87,15 @@ describe 'Inspec::Resources::Package' do
_(resource.info).must_equal pkg
end
# darwin (brew)
it 'verify brew package parsing' do
resource = MockLoader.new(:osx104).load_resource('package', 'curl')
pkg = { name: 'curl', installed: true, version: '7.52.1', type: 'brew' }
_(resource.installed?).must_equal true
_(resource.version).must_equal '7.52.1'
_(resource.info).must_equal pkg
end
# undefined
it 'verify package handling on unsupported os' do
resource = MockLoader.new(:undefined).load_resource('package', 'curl')