mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-24 08:00:17 -06:00
b9a93a0fe7
This is part of a general effort to move all of Terraform's non-library package surface under internal in order to reinforce that these are for internal use within Terraform only. If you were previously importing packages under this prefix into an external codebase, you could pin to an earlier release tag as an interim solution until you've make a plan to achieve the same functionality some other way.
58 lines
942 B
Go
58 lines
942 B
Go
package addrs
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestModuleEqual_true(t *testing.T) {
|
|
modules := []Module{
|
|
RootModule,
|
|
{"a"},
|
|
{"a", "b"},
|
|
{"a", "b", "c"},
|
|
}
|
|
for _, m := range modules {
|
|
t.Run(m.String(), func(t *testing.T) {
|
|
if !m.Equal(m) {
|
|
t.Fatalf("expected %#v to be equal to itself", m)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestModuleEqual_false(t *testing.T) {
|
|
testCases := []struct {
|
|
left Module
|
|
right Module
|
|
}{
|
|
{
|
|
RootModule,
|
|
Module{"a"},
|
|
},
|
|
{
|
|
Module{"a"},
|
|
Module{"b"},
|
|
},
|
|
{
|
|
Module{"a"},
|
|
Module{"a", "a"},
|
|
},
|
|
{
|
|
Module{"a", "b"},
|
|
Module{"a", "B"},
|
|
},
|
|
}
|
|
for _, tc := range testCases {
|
|
t.Run(fmt.Sprintf("%s = %s", tc.left, tc.right), func(t *testing.T) {
|
|
if tc.left.Equal(tc.right) {
|
|
t.Fatalf("expected %#v not to be equal to %#v", tc.left, tc.right)
|
|
}
|
|
|
|
if tc.right.Equal(tc.left) {
|
|
t.Fatalf("expected %#v not to be equal to %#v", tc.right, tc.left)
|
|
}
|
|
})
|
|
}
|
|
}
|