| 1 | // Copyright IBM Corp. 2020, 2025 |
| 2 | // SPDX-License-Identifier: MPL-2.0 |
| 3 | |
| 4 | package collectionscip-go gomod github.com/hashicorp/go-cty-funcs . `github.com/hashicorp/go-cty-funcs/collection`/ |
| 5 | |
| 6 | import ( |
| 7 | "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 8 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 9 | |
| 10 | "github.com/zclconf/go-cty/ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/" |
| 11 | ) |
| 12 | |
| 13 | func TestCoalescescip-go gomod github.com/hashicorp/go-cty-funcs . `github.com/hashicorp/go-cty-funcs/collection`/TestCoalesce().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 14 | tests := []struct { |
| 15 | Values []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value# |
| 16 | Want ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value# |
| 17 | Err bool |
| 18 | }{ |
| 19 | { |
| 20 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("first"), ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("second"), ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("third")}, |
| 21 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("first"), |
| 22 | false, |
| 23 | }, |
| 24 | { |
| 25 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().(""), ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("second"), ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("third")}, |
| 26 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("second"), |
| 27 | false, |
| 28 | }, |
| 29 | { |
| 30 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().(""), ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("")}, |
| 31 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.NilValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/NilVal., |
| 32 | true, |
| 33 | }, |
| 34 | { |
| 35 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Truescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/True.}, |
| 36 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Truescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/True., |
| 37 | false, |
| 38 | }, |
| 39 | { |
| 40 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.NullValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/NullVal().(ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Bool.), ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Truescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/True.}, |
| 41 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Truescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/True., |
| 42 | false, |
| 43 | }, |
| 44 | { |
| 45 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.NullValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/NullVal().(ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Bool.), ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Falsescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/False.}, |
| 46 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Falsescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/False., |
| 47 | false, |
| 48 | }, |
| 49 | { |
| 50 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.NullValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/NullVal().(ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Bool.), ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Falsescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/False., ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("hello")}, |
| 51 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("false"), |
| 52 | false, |
| 53 | }, |
| 54 | { |
| 55 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Truescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/True., ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.UnknownValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/UnknownVal().(ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Bool.)}, |
| 56 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Truescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/True., |
| 57 | false, |
| 58 | }, |
| 59 | { |
| 60 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.UnknownValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/UnknownVal().(ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Bool.), ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Truescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/True.}, |
| 61 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.UnknownValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/UnknownVal().(ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Bool.), |
| 62 | false, |
| 63 | }, |
| 64 | { |
| 65 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.UnknownValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/UnknownVal().(ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Bool.), ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().("hello")}, |
| 66 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.UnknownValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/UnknownVal().(ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/String.), |
| 67 | false, |
| 68 | }, |
| 69 | { |
| 70 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.DynamicValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/DynamicVal., ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Truescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/True.}, |
| 71 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.UnknownValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/UnknownVal().(ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Bool.), |
| 72 | false, |
| 73 | }, |
| 74 | { |
| 75 | []ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.DynamicValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/DynamicVal.}, |
| 76 | ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.DynamicValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/DynamicVal., |
| 77 | false, |
| 78 | }, |
| 79 | } |
| 80 | |
| 81 | for _, test := range tests { |
| 82 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("Coalesce(%#v...)", test.Values), func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 83 | got, err := Coalescescip-go gomod github.com/hashicorp/go-cty-funcs . `github.com/hashicorp/go-cty-funcs/collection`/Coalesce().(test.Values...) |
| 84 | |
| 85 | if test.Err { |
| 86 | if err == nil { |
| 87 | t.Fatalscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatal().("succeeded; want error") |
| 88 | } |
| 89 | return |
| 90 | } else if err != nil { |
| 91 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("unexpected error: %s", err) |
| 92 | } |
| 93 | |
| 94 | if !got.RawEqualsscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#RawEquals().(test.Want) { |
| 95 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("wrong result\ngot: %#v\nwant: %#v", got, test.Want) |
| 96 | } |
| 97 | }) |
| 98 | } |
| 99 | } |