2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "resources/aws/aws_billing_reports"
|
2019-05-21 00:19:38 +00:00
|
|
|
|
2019-07-27 20:04:43 +00:00
|
|
|
require "unit/mock/files/aws_billing_backend"
|
2019-01-10 00:06:48 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
require "resource_support/aws"
|
|
|
|
require "resources/aws/aws_billing_reports"
|
2019-05-21 00:19:38 +00:00
|
|
|
|
2019-01-10 00:06:48 +00:00
|
|
|
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
|
2019-06-11 22:24:35 +00:00
|
|
|
assert AwsBillingReports.new.report_names.include?("inspec1")
|
2019-01-10 00:06:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_where_hit
|
|
|
|
abr = AwsBillingReports.new.where { report_name =~ /inspec.*/ }
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_includes abr.time_units, "daily"
|
|
|
|
assert_includes abr.compressions, "zip"
|
|
|
|
assert_includes abr.s3_buckets, "inspec1-s3-bucket"
|
2019-01-10 00:06:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class PaginatedAwsBillingReportsTest < Minitest::Test
|
|
|
|
def setup
|
|
|
|
AwsBillingReports::BackendFactory.select(MockAwsBillingReports::Paginated)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_paginated_search_hit_via_scalar
|
2019-06-11 22:24:35 +00:00
|
|
|
assert AwsBillingReports.new.report_names.include?("inspec12")
|
2019-01-10 00:06:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_paginated_search_miss_via_scalar
|
2019-06-11 22:24:35 +00:00
|
|
|
refute AwsBillingReports.new.report_names.include?("non-existent")
|
2019-01-10 00:06:48 +00:00
|
|
|
end
|
|
|
|
end
|