Пример #1
0
func TestFlash_Set_withNil(t *testing.T) {
	f := kocha.Flash(nil)
	key := "test_key"
	value := "test_value"
	f.Set(key, value)
	actual := f.Len()
	expected := 0
	if !reflect.DeepEqual(actual, expected) {
		t.Errorf(`Flash.Set(%#v, %#v); Flash.Len() => %#v; want %#v`, key, value, actual, expected)
	}
}
Пример #2
0
func TestFlashMiddleware_Before_withNilSession(t *testing.T) {
	app := kocha.NewTestApp()
	m := &kocha.FlashMiddleware{}
	c := &kocha.Context{Session: nil}
	err := m.Process(app, c, func() error {
		actual := c.Flash
		expect := kocha.Flash(nil)
		if !reflect.DeepEqual(actual, expect) {
			t.Errorf(`FlashMiddleware.Process(app, c, func) => %#v; want %#v`, actual, expect)
		}
		return fmt.Errorf("expected error")
	})
	var actual interface{} = err
	var expect interface{} = fmt.Errorf("expected error")
	if !reflect.DeepEqual(actual, expect) {
		t.Errorf(`kocha.FlashMiddleware.Process(app, c, func) => %#v; want %#v`, actual, expect)
	}
	actual = c.Flash
	expect = kocha.Flash(nil)
	if !reflect.DeepEqual(actual, expect) {
		t.Errorf(`FlashMiddleware.Process(app, c, func) => %#v; want %#v`, actual, expect)
	}
}
Пример #3
0
func TestFlash_Get_withNil(t *testing.T) {
	f := kocha.Flash(nil)
	key := "test_key"
	var actual interface{} = f.Get(key)
	var expected interface{} = ""
	if !reflect.DeepEqual(actual, expected) {
		t.Errorf(`Flash.Get(%#v) => %#v; want %#v`, key, actual, expected)
	}

	actual = f.Len()
	expected = 0
	if !reflect.DeepEqual(actual, expected) {
		t.Errorf(`Flash.Get(%#v); Flash.Len() => %#v; want %#v`, key, actual, expected)
	}
}