github.com/opentofu/opentofu@v1.7.1/internal/providers/addressed_types_test.go (about)

     1  // Copyright (c) The OpenTofu Authors
     2  // SPDX-License-Identifier: MPL-2.0
     3  // Copyright (c) 2023 HashiCorp, Inc.
     4  // SPDX-License-Identifier: MPL-2.0
     5  
     6  package providers
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/go-test/deep"
    12  
    13  	"github.com/opentofu/opentofu/internal/addrs"
    14  )
    15  
    16  func TestAddressedTypesAbs(t *testing.T) {
    17  	providerAddrs := []addrs.AbsProviderConfig{
    18  		addrs.AbsProviderConfig{
    19  			Module:   addrs.RootModule,
    20  			Provider: addrs.NewDefaultProvider("aws"),
    21  		},
    22  		addrs.AbsProviderConfig{
    23  			Module:   addrs.RootModule,
    24  			Provider: addrs.NewDefaultProvider("aws"),
    25  			Alias:    "foo",
    26  		},
    27  		addrs.AbsProviderConfig{
    28  			Module:   addrs.RootModule,
    29  			Provider: addrs.NewDefaultProvider("azure"),
    30  		},
    31  		addrs.AbsProviderConfig{
    32  			Module:   addrs.RootModule,
    33  			Provider: addrs.NewDefaultProvider("null"),
    34  		},
    35  		addrs.AbsProviderConfig{
    36  			Module:   addrs.RootModule,
    37  			Provider: addrs.NewDefaultProvider("null"),
    38  		},
    39  	}
    40  
    41  	got := AddressedTypesAbs(providerAddrs)
    42  	want := []addrs.Provider{
    43  		addrs.NewDefaultProvider("aws"),
    44  		addrs.NewDefaultProvider("azure"),
    45  		addrs.NewDefaultProvider("null"),
    46  	}
    47  	for _, problem := range deep.Equal(got, want) {
    48  		t.Error(problem)
    49  	}
    50  }