opentofu icon indicating copy to clipboard operation
opentofu copied to clipboard

mock_provider still expects configuration attributes

Open berahtlv opened this issue 1 year ago • 1 comments

OpenTofu Version

OpenTofu v1.8.2

OpenTofu Configuration Files

main.tf

terraform {
  required_version = ">=1.5.0"

  required_providers {
    netbox = {
      source  = "e-breuninger/netbox"
      version = "3.6.2"
    }
  }
}

variable "platform" {
  description = "Device Platform"
  type        = string
  default     = "Linux"
}

data "netbox_platform" "default" {
  name = var.platform
}

main.tftest.hcl

mock_provider "netbox" {}

run "netbox_platform" {

  command = plan

  variables {
    platform = "tofutest"
  }

  assert {
    condition     = var.platform == "tofutest"
    error_message = "Value is incorrect"
  }
}

Debug Output

tofu test

main.tftest.hcl... fail
  run "netbox_platform"... fail
╷
│ Error: Missing required attribute
│ 
│   on provider["registry.opentofu.org/e-breuninger/netbox"] with no configuration line 1:
│   (source code not available)
│ 
│ The attribute "api_token" is required, but no definition was found.
╵
╷
│ Error: Missing required attribute
│ 
│   on provider["registry.opentofu.org/e-breuninger/netbox"] with no configuration line 1:
│   (source code not available)
│ 
│ The attribute "server_url" is required, but no definition was found.
╵

Failure! 0 passed, 1 failed.

Expected Behavior

The test should pass. Terraform 1.9.6 is passing successfully.

Actual Behavior

Provider requires api_token and server_url configuration attributes. Can be set with NETBOX_API_TOKEN and NETBOX_SERVER_URL environment variables.

Steps to Reproduce

tofu test

Additional Context

No response

References

No response

berahtlv avatar Oct 02 '24 08:10 berahtlv

Hello and thank you for the report! The core team regularly reviews new issues and discusses them, but this can take a little time. Please bear with us while we get to your issue. If you're interested, the contribution guide has a section about the decision-making process.

cam72cam avatar Oct 03 '24 15:10 cam72cam

Thanks for the bug report! This issue is the same as #2139 and will be fixed by #2140.

ollevche avatar Nov 11 '24 12:11 ollevche