mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
di: minor
This commit is contained in:
parent
c1b31ab102
commit
fa81c596df
|
@ -77,6 +77,11 @@ func TestDependency(t *testing.T) {
|
|||
},
|
||||
Expected: false,
|
||||
},
|
||||
{
|
||||
|
||||
Dependency: map[string]string{"test": "value"},
|
||||
Expected: map[string]string{"test": "value"},
|
||||
},
|
||||
}
|
||||
|
||||
testDependencies(t, tests)
|
||||
|
|
|
@ -204,12 +204,15 @@ type testMessage struct {
|
|||
Body string
|
||||
}
|
||||
|
||||
type myMap map[string]*testMessage
|
||||
|
||||
func TestDependentDependencies(t *testing.T) {
|
||||
b := New()
|
||||
b.Register(&testServiceImpl{prefix: "prefix:"})
|
||||
b.Register(func(service testService) testMessage {
|
||||
return testMessage{Body: service.Say("it is a deep") + " dependency"}
|
||||
})
|
||||
b.Register(myMap{"test": &testMessage{Body: "value"}})
|
||||
var (
|
||||
h1 = b.Handler(func(msg testMessage) string {
|
||||
return msg.Body
|
||||
|
@ -217,15 +220,20 @@ func TestDependentDependencies(t *testing.T) {
|
|||
h2 = b.Handler(func(reuse testService) string {
|
||||
return reuse.Say("message")
|
||||
})
|
||||
h3 = b.Handler(func(m myMap) string {
|
||||
return m["test"].Body
|
||||
})
|
||||
)
|
||||
|
||||
app := iris.New()
|
||||
app.Get("/h1", h1)
|
||||
app.Get("/h2", h2)
|
||||
app.Get("/h3", h3)
|
||||
|
||||
e := httptest.New(t, app)
|
||||
e.GET("/h1").Expect().Status(httptest.StatusOK).Body().Equal("prefix: it is a deep dependency")
|
||||
e.GET("/h2").Expect().Status(httptest.StatusOK).Body().Equal("prefix: message")
|
||||
e.GET("/h3").Expect().Status(httptest.StatusOK).Body().Equal("value")
|
||||
}
|
||||
|
||||
func TestHandlerPathParams(t *testing.T) {
|
||||
|
|
|
@ -231,8 +231,10 @@ func isZero(v reflect.Value) bool {
|
|||
return len(v.Interface().(net.IP)) == 0
|
||||
}
|
||||
|
||||
zero := reflect.Zero(v.Type())
|
||||
return v.Interface() == zero.Interface()
|
||||
// zero := reflect.Zero(v.Type())
|
||||
// return v.Interface() == zero.Interface()
|
||||
|
||||
return v.IsZero()
|
||||
}
|
||||
|
||||
// IsNil same as `reflect.IsNil` but a bit safer to use, returns false if not a correct type.
|
||||
|
|
Loading…
Reference in New Issue
Block a user