Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MS Defender Integration tests failing #185

Open
chris-rock opened this issue Dec 16, 2024 · 2 comments
Open

MS Defender Integration tests failing #185

chris-rock opened this issue Dec 16, 2024 · 2 comments

Comments

@chris-rock
Copy link
Member

Describe the bug

on latest main the following tests are failing:

=== RUN   TestAccMsDefenderIntegrationResource
    integration_msdefender_resource_test.go:14: Step 1/4 error: Error running apply: exit status 1
        
        Error: Missing Resource State After Create
        
          with mondoo_integration_msdefender.msdefender_integration,
          on terraform_plugin_test.tf line 12, in resource "mondoo_integration_msdefender" "msdefender_integration":
          12: resource "mondoo_integration_msdefender" "msdefender_integration" {
        
        The Terraform Provider unexpectedly returned no resource state after having
        no errors in the resource creation. This is always an issue in the Terraform
        Provider and should be reported to the provider developers.
        
        The resource may have been successfully created, but Terraform is not
        tracking it. Applying the configuration again with no other action may result
        in duplicate resource errors. Import the resource if the resource was
        actually created and Terraform should be tracking it.

To Reproduce

Run tests on latest main, see https://github.com/mondoohq/terraform-provider-mondoo/actions/runs/12348500045/job/34457483333

Expected behavior

Tests pass

@mati007thm
Copy link
Contributor

#186

@mati007thm
Copy link
Contributor

Found the error:

// trigger integration to gather results quickly after the first setup
// NOTE: we ignore the error since the integration state does not depend on it
_, err = r.client.TriggerAction(ctx, string(integration.Mrn), mondoov1.ActionTypeRunScan)
if err != nil {
    resp.Diagnostics.
        AddWarning("Client Error",
            fmt.Sprintf("Unable to trigger integration, got error: %s", err),
        )
    return
}

The return here stops the code before data is written to the state. This implementation is found in many other integrations like GitHub and GCP. I think this should be changed. Simply remove the return statement since it is only a warning anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants