@@ -2,6 +2,7 @@ package audittrail_test
22
33import (
44 "fmt"
5+ "regexp"
56 "testing"
67
78 "github.com/google/uuid"
@@ -139,3 +140,37 @@ func TestAccDataSourceEvent_Basic(t *testing.T) {
139140 },
140141 })
141142}
143+
144+ func TestAccDataSourceEvent_Warning (t * testing.T ) {
145+ // Test that a resource_type that is not yet supported on the
146+ // provider only raises a warning before calling the API
147+ // anyway (it could exist on API side)
148+
149+ // NOTE: Currently, we cannot programmatically assert that a warning was emitted
150+ // during the test step. This needs support from the testing framework:
151+ // https://github.com/hashicorp/terraform-plugin-testing/issues/69
152+ // Once implemented, we should add a check like:
153+ // ExpectWarning: regexp.MustCompile(`expected resourceType to be one of [\"unknown_type\" \"secm_secret\" \"secm_secret_version\" \"kube_cluster\" \"kube_pool\" \"kube_node\" \"kube_acl\" \"keym_key\" \"iam_user\" \"iam_application\" \"iam_group\" \"iam_policy\" \"iam_api_key\" \"iam_ssh_key\" \"iam_rule\" \"iam_saml\" \"iam_saml_certificate\" \"secret_manager_secret\" \"secret_manager_version\" \"key_manager_key\" \"account_user\" \"account_organization\" \"account_project\" \"instance_server\" \"instance_placement_group\" \"instance_security_group\" \"instance_volume\" \"instance_snapshot\" \"instance_image\" \"apple_silicon_server\" \"baremetal_server\" \"baremetal_setting\" \"ipam_ip\" \"sbs_volume\" \"sbs_snapshot\" \"load_balancer_lb\" \"load_balancer_ip\" \"load_balancer_frontend\" \"load_balancer_backend\" \"load_balancer_route\" \"load_balancer_acl\" \"load_balancer_certificate\" \"sfs_filesystem\" \"vpc_private_network\"], got a_new_resource_type`)
154+ tt := acctest .NewTestTools (t )
155+ defer tt .Cleanup ()
156+
157+ resource .ParallelTest (t , resource.TestCase {
158+ ProtoV6ProviderFactories : tt .ProviderFactories ,
159+ CheckDestroy : testAccCheckSecretDestroy (tt ),
160+ Steps : []resource.TestStep {
161+ {
162+ Config : `
163+ data "scaleway_audit_trail_event" "unknown_resource_type" {
164+ resource_type = "a_new_resource_type"
165+ }
166+ ` ,
167+ Check : resource .ComposeTestCheckFunc (
168+ resource .TestCheckResourceAttr ("data.scaleway_audit_trail_event.unknown_resource_type" , "events.#" , "0" ),
169+ ),
170+ // In this test, we still expect a 400 from the API since `a_new_resource_type`
171+ // does not actually exist on API side.
172+ ExpectError : regexp .MustCompile (`400 Bad Request` ),
173+ },
174+ },
175+ })
176+ }
0 commit comments