mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-29 11:50:37 +00:00
35 lines
600 B
Go
35 lines
600 B
Go
|
package cache
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/franela/goblin"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
func TestCache(t *testing.T) {
|
||
|
|
||
|
g := goblin.Goblin(t)
|
||
|
g.Describe("Cache", func() {
|
||
|
|
||
|
var c *gin.Context
|
||
|
g.BeforeEach(func() {
|
||
|
c = new(gin.Context)
|
||
|
ToContext(c, Default())
|
||
|
})
|
||
|
|
||
|
g.It("Should set and get an item", func() {
|
||
|
Set(c, "foo", "bar")
|
||
|
v, e := Get(c, "foo")
|
||
|
g.Assert(v).Equal("bar")
|
||
|
g.Assert(e == nil).IsTrue()
|
||
|
})
|
||
|
|
||
|
g.It("Should return nil when item not found", func() {
|
||
|
v, e := Get(c, "foo")
|
||
|
g.Assert(v == nil).IsTrue()
|
||
|
g.Assert(e == nil).IsFalse()
|
||
|
})
|
||
|
})
|
||
|
}
|