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

Function TestDecodeFrom_BasicSquash

mapstructure_test.go:444–472  ·  mapstructure_test.go::TestDecodeFrom_BasicSquash
(t *testing.T)

Source from the content-addressed store, hash-verified

442}
443
444func TestDecodeFrom_BasicSquash(t *testing.T) {
445 t.Parallel()
446
447 var v interface{}
448 var ok bool
449
450 input := BasicSquash{
451 Test: Basic{
452 Vstring: "foo",
453 },
454 }
455
456 var result map[string]interface{}
457 err := Decode(input, &result)
458 if err != nil {
459 t.Fatalf("got an err: %s", err.Error())
460 }
461
462 if _, ok = result["Test"]; ok {
463 t.Error("test should not be present in map")
464 }
465
466 v, ok = result["Vstring"]
467 if !ok {
468 t.Error("vstring should be present in map")
469 } else if !reflect.DeepEqual(v, "foo") {
470 t.Errorf("vstring value should be 'foo': %#v", v)
471 }
472}
473
474func TestDecode_Embedded(t *testing.T) {
475 t.Parallel()

Callers

nothing calls this directly

Calls 2

DecodeFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected