Migrate from templates to Gomponents (#103)
This commit is contained in:
parent
0bf9ab7189
commit
051d032038
104 changed files with 2768 additions and 2824 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -22,3 +23,25 @@ func TestIsCanceled(t *testing.T) {
|
|||
|
||||
assert.False(t, IsCanceledError(errors.New("test error")))
|
||||
}
|
||||
|
||||
func TestCache(t *testing.T) {
|
||||
ctx := echo.New().NewContext(nil, nil)
|
||||
|
||||
key := "testing"
|
||||
value := "hello"
|
||||
called := 0
|
||||
callback := func(ctx echo.Context) string {
|
||||
called++
|
||||
return value
|
||||
}
|
||||
|
||||
assert.Nil(t, ctx.Get(key))
|
||||
|
||||
got := Cache(ctx, key, callback)
|
||||
assert.Equal(t, value, got)
|
||||
assert.Equal(t, 1, called)
|
||||
|
||||
got = Cache(ctx, key, callback)
|
||||
assert.Equal(t, value, got)
|
||||
assert.Equal(t, 1, called)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue