Terraform provider testing when using mux

When using terraform provider, and migrating it to use both the sdk v2 and plugin framework, I am running into

flag redefined: sweep
flag redefined: sweep

goroutine 1 [running]:
flag.(*FlagSet).Var(0x140001b0150, {0x108844438, 0x140007faf10}, {0x106cb8bd7, 0x5}, {0x106daffff, 0x29})
        sdk/go1.22.5/src/flag/flag.go:1028 +0x2cc
flag.(*FlagSet).StringVar(...)
        sdk/go1.22.5/src/flag/flag.go:879
flag.(*FlagSet).String(0x140001b0150, {0x106cb8bd7, 0x5}, {0x0, 0x0}, {0x106daffff, 0x29})
        sdk/go1.22.5/src/flag/flag.go:892 +0x98
flag.String(...)
        sdk/go1.22.5/src/flag/flag.go:899
github.com/hashicorp/terraform-plugin-testing/helper/resource.init()
        go/pkg/mod/github.com/hashicorp/terraform-plugin-testing@v1.3.0/helper/resource/testing.go:55 +0x44

I followed the guidelines on this,still I the error persists

Hey there @ramuklawjju :wave: , without seeing the source code I can’t offer any specific guidance on what to adjust, but there is a very similar bug report here:

It’s possible that there are still some lingering github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource references in your code base, as the error message suggests that there are two imports defining the sweep flag, specifically:

  • Old: github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource
  • New: github.com/hashicorp/terraform-plugin-testing/helper/resource

In the past, the migration guide only mentioned _test.go files that needed to change, but now there are .go files that need to change as well (mentioned in that migration steps section you linked), some of them don’t reference the resource package anymore and have new package names like retry and id

1 Like