PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/render_test.go

http://github.com/sut-go/gon
Go | 30 lines | 26 code | 4 blank | 0 comment | 0 complexity | 373c3593105a6b8257bef82ffb650210 MD5 | raw file
 1package starter
 2
 3import . "framework/mv"
 4import "github.com/bmizerany/assert"
 5import "testing"
 6import "reflect"
 7
 8type MockWebContext struct {
 9    result string
10}
11func (c *MockWebContext) WriteString(content string) {
12    c.result = content
13}
14func (c *MockWebContext) GetParams() map[string]string {
15    return map[string]string{"k":"v"}
16}
17
18func TestRenderDefault_ReturnModel(test *testing.T) {
19    c := new(MockWebContext)
20    ret := []reflect.Value{reflect.ValueOf(Model{"key":"test"})}
21    renderDefault(c, ret, "mock","index")
22    assert.Equal(test, c.result, "mock-test")
23}
24
25func TestRenderDefault_ReturnView(test *testing.T) {
26    c := new(MockWebContext)
27    ret := []reflect.Value{reflect.ValueOf(View("index"))}
28    renderDefault(c, ret, "mock","non-index")
29    assert.Equal(test, c.result, "mock-")
30}