MCPcopy
hub / github.com/mitchellh/mapstructure / TestDecode_EmbeddedSlice

Function TestDecode_EmbeddedSlice

mapstructure_test.go:528–549  ·  mapstructure_test.go::TestDecode_EmbeddedSlice
(t *testing.T)

Source from the content-addressed store, hash-verified

526}
527
528func TestDecode_EmbeddedSlice(t *testing.T) {
529 t.Parallel()
530
531 input := map[string]interface{}{
532 "slice_alias": []string{"foo", "bar"},
533 "vunique": "bar",
534 }
535
536 var result EmbeddedSlice
537 err := Decode(input, &result)
538 if err != nil {
539 t.Fatalf("got an err: %s", err.Error())
540 }
541
542 if !reflect.DeepEqual(result.SliceAlias, SliceAlias([]string{"foo", "bar"})) {
543 t.Errorf("slice value: %#v", result.SliceAlias)
544 }
545
546 if result.Vunique != "bar" {
547 t.Errorf("vunique value should be 'bar': %#v", result.Vunique)
548 }
549}
550
551func TestDecode_EmbeddedArray(t *testing.T) {
552 t.Parallel()

Callers

nothing calls this directly

Calls 3

DecodeFunction · 0.85
SliceAliasTypeAlias · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected