Debian Codegraph @

cty/convert/mismatch_msg_test.go

raw symbols SCIP
1 package convertscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/convert`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/"
5 "testingscip-go gomod github.com/golang/go/src go1.18 testing/"
6
7 "github.com/zclconf/go-cty/ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/"
8 )
9
10 func TestMismatchMessagescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/convert`/TestMismatchMessage().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
11 tests := []struct {
12 GotType, WantType ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#
13 WantMsg string
14 }{
15 {
16 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Bool.,
17 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Numberscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Number.,
18 `number required`,
19 },
20 {
21 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject.,
22 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
23 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
24 }),
25 `attribute "foo" is required`,
26 },
27 {
28 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject.,
29 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
30 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
31 "bar": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
32 }),
33 `attributes "bar" and "foo" are required`,
34 },
35 {
36 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject.,
37 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
38 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
39 "bar": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
40 "baz": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
41 }),
42 `attributes "bar", "baz", and "foo" are required`,
43 },
44 {
45 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject.,
46 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Listscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/List().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
47 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
48 "bar": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
49 "baz": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
50 })),
51 `list of object required`,
52 },
53 {
54 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Listscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/List().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.),
55 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Listscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/List().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
56 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
57 })),
58 `incorrect list element type: object required`,
59 },
60 {
61 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Listscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/List().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject.),
62 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Listscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/List().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
63 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
64 })),
65 `incorrect list element type: attribute "foo" is required`,
66 },
67 {
68 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Tuplescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Tuple().([]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject.}),
69 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Listscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/List().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
70 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
71 })),
72 `element 0: attribute "foo" is required`,
73 },
74 {
75 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Listscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/List().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject.),
76 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Set().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
77 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
78 })),
79 `incorrect set element type: attribute "foo" is required`,
80 },
81 {
82 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Tuplescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Tuple().([]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject.}),
83 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Set().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
84 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
85 })),
86 `element 0: attribute "foo" is required`,
87 },
88 {
89 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Mapscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Map().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject.),
90 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Mapscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Map().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
91 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
92 })),
93 `incorrect map element type: attribute "foo" is required`,
94 },
95 {
96 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{"boop": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject.}),
97 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Mapscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Map().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
98 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
99 })),
100 `element "boop": attribute "foo" is required`,
101 },
102 {
103 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Tuplescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Tuple().([]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyObjectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyObject., ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.EmptyTuplescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/EmptyTuple.}),
104 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Listscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/List().(ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.DynamicPseudoTypescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/DynamicPseudoType.),
105 `all list elements must have the same type`,
106 },
107 {
108 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
109 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Bool.,
110 "bar": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
111 "baz": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
112 "boop": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Numberscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Number.,
113 }),
114 }),
115 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
116 "foo": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Bool.,
117 "bar": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/String.,
118 "baz": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Objectscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Object().(map[string]ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Type#{
119 "boop": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Numberscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Number.,
120 "beep": ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Bool.,
121 }),
122 }),
123 `attribute "baz": attribute "beep" is required`,
124 },
125 }
126
127 for _, test := range tests {
128 t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%#v but want %#v", test.GotType, test.WantType), func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
129 got := MismatchMessagescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/convert`/MismatchMessage().(test.GotType, test.WantType)
130 if got != test.WantMsg {
131 t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("wrong message\ngot type: %#v\nwant type: %#v\ngot message: %s\nwant message: %s", test.GotType, test.WantType, got, test.WantMsg)
132 }
133 })
134 }
135 }