@@ -124,118 +124,68 @@ func TestReplaceIndexInIndexPattern(t *testing.T) {
124124 index string
125125 expected common.MapStr
126126 }{
127- {
128- title : "Replace in []interface(map).map" ,
129- input : common.MapStr {"objects" : []interface {}{map [string ]interface {}{
130- "id" : "phonybeat-*" ,
131- "type" : "index-pattern" ,
132- "attributes" : map [string ]interface {}{
133- "title" : "phonybeat-*" ,
134- "timeFieldName" : "@timestamp" ,
135- }}}},
136- index : "otherindex-*" ,
137- expected : common.MapStr {"objects" : []interface {}{map [string ]interface {}{
138- "id" : "otherindex-*" ,
139- "type" : "index-pattern" ,
140- "attributes" : map [string ]interface {}{
141- "title" : "otherindex-*" ,
142- "timeFieldName" : "@timestamp" ,
143- }}}},
144- },
145- {
146- title : "Replace in []interface(map).mapstr" ,
147- input : common.MapStr {"objects" : []interface {}{map [string ]interface {}{
148- "id" : "phonybeat-*" ,
149- "type" : "index-pattern" ,
150- "attributes" : common.MapStr {
151- "title" : "phonybeat-*" ,
152- "timeFieldName" : "@timestamp" ,
153- }}}},
154- index : "otherindex-*" ,
155- expected : common.MapStr {"objects" : []interface {}{map [string ]interface {}{
156- "id" : "otherindex-*" ,
157- "type" : "index-pattern" ,
158- "attributes" : common.MapStr {
159- "title" : "otherindex-*" ,
160- "timeFieldName" : "@timestamp" ,
161- }}}},
162- },
163- {
164- title : "Replace in []map.mapstr" ,
165- input : common.MapStr {"objects" : []map [string ]interface {}{{
166- "id" : "phonybeat-*" ,
167- "type" : "index-pattern" ,
168- "attributes" : common.MapStr {
169- "title" : "phonybeat-*" ,
170- "timeFieldName" : "@timestamp" ,
171- }}}},
172- index : "otherindex-*" ,
173- expected : common.MapStr {"objects" : []map [string ]interface {}{{
174- "id" : "otherindex-*" ,
175- "type" : "index-pattern" ,
176- "attributes" : common.MapStr {
177- "title" : "otherindex-*" ,
178- "timeFieldName" : "@timestamp" ,
179- }}}},
180- },
181127 {
182128 title : "Replace in []mapstr.mapstr" ,
183- input : common.MapStr {"objects" : []common. MapStr {{
129+ input : common.MapStr {
184130 "id" : "phonybeat-*" ,
185131 "type" : "index-pattern" ,
186132 "attributes" : common.MapStr {
187133 "title" : "phonybeat-*" ,
188134 "timeFieldName" : "@timestamp" ,
189- }}}} ,
135+ }},
190136 index : "otherindex-*" ,
191- expected : common.MapStr {"objects" : []common. MapStr {{
137+ expected : common.MapStr {
192138 "id" : "otherindex-*" ,
193139 "type" : "index-pattern" ,
194140 "attributes" : common.MapStr {
195141 "title" : "otherindex-*" ,
196142 "timeFieldName" : "@timestamp" ,
197- }}}} ,
143+ }},
198144 },
199145 {
200146 title : "Replace in []mapstr.interface(mapstr)" ,
201- input : common.MapStr {"objects" : []common. MapStr {{
147+ input : common.MapStr {
202148 "id" : "phonybeat-*" ,
203149 "type" : "index-pattern" ,
204150 "attributes" : interface {}(common.MapStr {
205151 "title" : "phonybeat-*" ,
206152 "timeFieldName" : "@timestamp" ,
207- })}}} ,
153+ })},
208154 index : "otherindex-*" ,
209- expected : common.MapStr {"objects" : []common. MapStr {{
155+ expected : common.MapStr {
210156 "id" : "otherindex-*" ,
211157 "type" : "index-pattern" ,
212158 "attributes" : interface {}(common.MapStr {
213159 "title" : "otherindex-*" ,
214160 "timeFieldName" : "@timestamp" ,
215- })}}} ,
161+ })},
216162 },
217163 {
218164 title : "Do not create missing attributes" ,
219- input : common.MapStr {"objects" : []common.MapStr {{
220- "id" : "phonybeat-*" ,
221- "type" : "index-pattern" ,
222- }}},
165+ input : common.MapStr {
166+ "attributes" : common.MapStr {},
167+ "id" : "phonybeat-*" ,
168+ "type" : "index-pattern" ,
169+ },
223170 index : "otherindex-*" ,
224- expected : common.MapStr {"objects" : []common.MapStr {{
225- "id" : "otherindex-*" ,
226- "type" : "index-pattern" ,
227- }}},
171+ expected : common.MapStr {
172+ "attributes" : common.MapStr {},
173+ "id" : "otherindex-*" ,
174+ "type" : "index-pattern" ,
175+ },
228176 },
229177 {
230178 title : "Create missing id" ,
231- input : common.MapStr {"objects" : []common.MapStr {{
232- "type" : "index-pattern" ,
233- }}},
179+ input : common.MapStr {
180+ "attributes" : common.MapStr {},
181+ "type" : "index-pattern" ,
182+ },
234183 index : "otherindex-*" ,
235- expected : common.MapStr {"objects" : []common.MapStr {{
236- "id" : "otherindex-*" ,
237- "type" : "index-pattern" ,
238- }}},
184+ expected : common.MapStr {
185+ "attributes" : common.MapStr {},
186+ "id" : "otherindex-*" ,
187+ "type" : "index-pattern" ,
188+ },
239189 },
240190 }
241191
0 commit comments