github.com/insolar/vanilla@v0.0.0-20201023172447-248fdf805322/injector/injector_test.go (about) 1 // Copyright 2020 Insolar Network Ltd. 2 // All rights reserved. 3 // This material is licensed under the Insolar License version 1.0, 4 // available at https://github.com/insolar/assured-ledger/blob/master/LICENSE.md. 5 6 package injector 7 8 import ( 9 "testing" 10 11 "github.com/stretchr/testify/assert" 12 ) 13 14 func TestGetDefaultInterfaceInjectionIDByPtr(t *testing.T) { 15 assert.Panics(t, func() { _, _ = GetInterfaceTypeAndValue(nil) }) 16 type TestInterface interface{} 17 var v TestInterface 18 assert.Panics(t, func() { _, _ = GetInterfaceTypeAndValue(v) }) 19 assert.Panics(t, func() { _, _ = GetInterfaceTypeAndValue(&v) }) 20 v = struct{}{} 21 _, vt := GetInterfaceTypeAndValue(&v) 22 assert.Equal(t, GetDefaultInjectionIDByType(vt), "injector.TestInterface") 23 assert.Panics(t, func() { _, _ = GetInterfaceTypeAndValue(v) }) 24 type TestStruct struct{} 25 var s = TestStruct{} 26 assert.Panics(t, func() { _, _ = GetInterfaceTypeAndValue(&s) }) 27 }