You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
terraform/internal/addrs/set_test.go

66 lines
1.2 KiB

// Copyright IBM Corp. 2014, 2026
// SPDX-License-Identifier: BUSL-1.1
package addrs
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestSetSortedNatural(t *testing.T) {
// We're using AbsResourceInstance here just because it happens to
// implement the required Less method, but this is intended as a test
// of SetSortedNatural itself, not of any particular type's Less
// implementation.
boop1 := AbsResourceInstance{
Module: RootModuleInstance,
Resource: ResourceInstance{
Resource: Resource{
Mode: ManagedResourceMode,
Type: "test",
Name: "boop1",
},
Key: NoKey,
},
}
boop2 := AbsResourceInstance{
Module: RootModuleInstance,
Resource: ResourceInstance{
Resource: Resource{
Mode: ManagedResourceMode,
Type: "test",
Name: "boop2",
},
Key: NoKey,
},
}
boop3 := AbsResourceInstance{
Module: RootModuleInstance,
Resource: ResourceInstance{
Resource: Resource{
Mode: ManagedResourceMode,
Type: "test",
Name: "boop3",
},
Key: NoKey,
},
}
s := MakeSet(
boop3,
boop2,
boop1,
)
got := SetSortedNatural(s)
want := []AbsResourceInstance{
boop1,
boop2,
boop3,
}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("wrong result\n%s", diff)
}
}