예제 #1
0
// No test really needed, I run this code instead of writiing main
func TestNew(t *testing.T) {
	var c Chain

	c = New()
	chk.AssertLog(t, len(c) == 0, "Empty chain is not if length zero")

	c = New(dummyMiddleware())
	chk.AssertLogf(t, len(c) == 1, "Chain with 1 mware was of length %d not 1", len(c))
}
예제 #2
0
func TestChainAppend(t *testing.T) {
	var c Chain

	c = New().Append(dummyMiddleware())
	chk.AssertLogf(t, len(c) == 1, "Append to empty Chain gave len of %d not 1", len(c))
	chk.AssertLog(t, c[0] != nil, "First middleware in chain exists")

	c = New().Append(dummyMiddleware(), dummyMiddleware()).Append(dummyMiddleware())
	chk.AssertLogf(t, len(c) == 3, "Append two times to empty Chain gave len of %d not 3", len(c))
}