inspec/test/unit
jtimberman d7fad68541 add "packages" resource
This pull request adds a packages resource so that we can check for pattern matches against all the packages on a system. This initially implements only dpkg support for debian-based platforms so we can cover this use case:

```ruby
describe packages(/^xserver-xorg.*/) do
  its("list") { should be_empty }
end
```

This uses FilterTable so we can supply additional queries, too.

```ruby
describe packages(/vi.+/).where { status != 'installed' } do
  its('statuses') { should be_empty }
end
```

Users can specify the name as a string or a regular expression. If it is a string, we will escape it and convert it to a regular expression to use in matching against the full returned list of packages. If it is a regular expression, we take that as is and use it to filter the results.

While some package management systems such as `dpkg` can take a shell glob argument to filter their results, we eschew this and require a regular expression to match multiple package names because we will need this to work across other platforms in the future. This means that the following:

```ruby
packages("vim")
```

Will return *all* the "vim" packages on the system. The `packages` resource will take `"vim"`, turn it into `/vim/`, and greedily match anything with "vim" in the name. To match only a single package named `vim`, it needs to be an anchored regular expression.

```ruby
packages(/^vim$/)
```

Signed-off-by: Joshua Timberman <joshua@chef.io>

Use entries instead of list

Added a few more tests and non installed package in output
Signed-off-by: Alex Pop <apop@chef.io>

fix lint

Signed-off-by: Alex Pop <apop@chef.io>

Signed-off-by: Joshua Timberman <joshua@chef.io>
2017-02-07 10:29:11 +00:00
..
dependencies Bump lockfile version to 1.0 2016-09-26 09:51:04 +01:00
dsl Provide a way to force it vs its for any argument 2017-02-03 19:26:02 +00:00
fetchers Change :shasum key to :sha256 for future upgrade 2016-09-21 10:51:04 +01:00
mock add "packages" resource 2017-02-07 10:29:11 +00:00
plugins Remove some warnings during the test run 2016-09-09 14:14:36 +01:00
profiles control and lib eval unit tests 2017-01-04 11:33:14 -05:00
resources add "packages" resource 2017-02-07 10:29:11 +00:00
source_readers Add GitFetcher and rework Fetchers+SourceReaders 2016-09-09 14:14:36 +01:00
utils bugfix: support nil entries in filter table 2016-10-05 13:04:00 +02:00
file_provider_test.rb Add GitFetcher and rework Fetchers+SourceReaders 2016-09-09 14:14:36 +01:00
shell_detector_test.rb Add inspec env command to configure shell tab-completion 2016-08-10 02:07:53 +01:00