moving caching w/ TTL to its own package

This commit is contained in:
Brad Rydzewski
2015-10-20 16:45:24 -07:00
parent efcab1210b
commit eb04d418d9
14 changed files with 275 additions and 112 deletions

View File

@@ -3,6 +3,7 @@ package cache
import (
"testing"
"github.com/drone/drone/cache"
"github.com/drone/drone/model"
"github.com/franela/goblin"
"github.com/gin-gonic/gin"
@@ -13,13 +14,13 @@ func TestReposCache(t *testing.T) {
g := goblin.Goblin(t)
g.Describe("Repo List Cache", func() {
var c *gin.Context
g.BeforeEach(func() {
cache.Purge()
c = new(gin.Context)
cache.ToContext(c, cache.Default())
})
g.It("should skip when no user session", func() {
c := &gin.Context{}
Perms(c)
_, ok := c.Get("perm")
@@ -27,9 +28,8 @@ func TestReposCache(t *testing.T) {
})
g.It("should get repos from cache", func() {
c := &gin.Context{}
c.Set("user", fakeUser)
set("repos/octocat", fakeRepos, 999)
cache.SetRepos(c, fakeUser, fakeRepos)
Repos(c)