inspec/test/unit/resources/aws_billing_reports_test.rb
Miah Johnson 15162bf920 Add resources for aws_billing_report and aws_billing_reports. (#2838)
Signed-off-by: Miah Johnson <miah@chia-pet.org>
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-01-09 16:06:48 -08:00

61 lines
1.6 KiB
Ruby

require 'helper'
require_relative 'aws_billing_backend'
class ConstructorAwsBillingReportsTest < Minitest::Test
def setup
AwsBillingReports::BackendFactory.select(MockAwsBillingReports::Empty)
end
def test_empty_params_ok
assert AwsBillingReports.new
end
def test_rejects_unrecognized_params
assert_raises(ArgumentError) { AwsBillingReports.new(unrecognized_param: 1) }
end
end
class EmptyAwsBillingReportsTest < Minitest::Test
def setup
AwsBillingReports::BackendFactory.select(MockAwsBillingReports::Empty)
end
def test_search_miss_reports_empty
refute AwsBillingReports.new.exists?
end
end
class BasicAwsBillingReportsTest < Minitest::Test
def setup
AwsBillingReports::BackendFactory.select(MockAwsBillingReports::Basic)
end
def test_search_hit_via_empty_filter
assert AwsBillingReports.new.exists?
end
def test_search_hit_properties
assert AwsBillingReports.new.report_names.include?('inspec1')
end
def test_where_hit
abr = AwsBillingReports.new.where { report_name =~ /inspec.*/ }
assert_includes abr.time_units, 'daily'
assert_includes abr.compressions, 'zip'
assert_includes abr.s3_buckets, 'inspec1-s3-bucket'
end
end
class PaginatedAwsBillingReportsTest < Minitest::Test
def setup
AwsBillingReports::BackendFactory.select(MockAwsBillingReports::Paginated)
end
def test_paginated_search_hit_via_scalar
assert AwsBillingReports.new.report_names.include?('inspec12')
end
def test_paginated_search_miss_via_scalar
refute AwsBillingReports.new.report_names.include?('non-existent')
end
end