This commit is contained in:
Thomas Boerger 2016-11-15 10:36:25 +01:00
Родитель ef0579616d
Коммит eb2f354061
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 5A388F55283960B6
1 изменённых файлов: 14 добавлений и 14 удалений

28
cache/helper_test.go поставляемый
Просмотреть файл

@ -20,13 +20,13 @@ func TestHelper(t *testing.T) {
g.Describe("Cache helpers", func() {
var c *gin.Context
var r *mock.Remote
var r *mocks.Remote
g.BeforeEach(func() {
c = new(gin.Context)
ToContext(c, Default())
r = new(mock.Remote)
r = new(mocks.Remote)
remote.ToContext(c, r)
})
@ -45,17 +45,17 @@ func TestHelper(t *testing.T) {
)
Set(c, key, fakePerm)
r.On("GetPerm", fakeUser, fakeRepo.Owner, fakeRepo.Name).Return(nil, fakeErr).Once()
r.On("GetPerm", fakeUser, fakeRepo.Owner, fakeRepo.Name).Return(nil, errFake).Once()
p, err := GetPerm(c, fakeUser, fakeRepo.Owner, fakeRepo.Name)
g.Assert(p).Equal(fakePerm)
g.Assert(err).Equal(nil)
})
g.It("Should get permissions error", func() {
r.On("GetPerm", fakeUser, fakeRepo.Owner, fakeRepo.Name).Return(nil, fakeErr).Once()
r.On("GetPerm", fakeUser, fakeRepo.Owner, fakeRepo.Name).Return(nil, errFake).Once()
p, err := GetPerm(c, fakeUser, fakeRepo.Owner, fakeRepo.Name)
g.Assert(p == nil).IsTrue()
g.Assert(err).Equal(fakeErr)
g.Assert(err).Equal(errFake)
})
g.It("Should set and get repos", func() {
@ -72,17 +72,17 @@ func TestHelper(t *testing.T) {
)
Set(c, key, fakeRepos)
r.On("GetRepos", fakeUser).Return(nil, fakeErr).Once()
r.On("GetRepos", fakeUser).Return(nil, errFake).Once()
p, err := GetRepos(c, fakeUser)
g.Assert(p).Equal(fakeRepos)
g.Assert(err).Equal(nil)
})
g.It("Should get repos error", func() {
r.On("GetRepos", fakeUser).Return(nil, fakeErr).Once()
r.On("GetRepos", fakeUser).Return(nil, errFake).Once()
p, err := GetRepos(c, fakeUser)
g.Assert(p == nil).IsTrue()
g.Assert(err).Equal(fakeErr)
g.Assert(err).Equal(errFake)
})
g.It("Should set and get teams", func() {
@ -98,17 +98,17 @@ func TestHelper(t *testing.T) {
)
Set(c, key, fakeTeams)
r.On("GetTeams", fakeUser).Return(nil, fakeErr).Once()
r.On("GetTeams", fakeUser).Return(nil, errFake).Once()
p, err := GetTeams(c, fakeUser)
g.Assert(p).Equal(fakeTeams)
g.Assert(err).Equal(nil)
})
g.It("Should get team error", func() {
r.On("GetTeams", fakeUser).Return(nil, fakeErr).Once()
r.On("GetTeams", fakeUser).Return(nil, errFake).Once()
p, err := GetTeams(c, fakeUser)
g.Assert(p == nil).IsTrue()
g.Assert(err).Equal(fakeErr)
g.Assert(err).Equal(errFake)
})
g.It("Should set and get members", func() {
@ -122,17 +122,17 @@ func TestHelper(t *testing.T) {
key := "members:drone"
Set(c, key, fakeMembers)
r.On("GetMembers", fakeUser, "drone").Return(nil, fakeErr).Once()
r.On("GetMembers", fakeUser, "drone").Return(nil, errFake).Once()
p, err := GetMembers(c, fakeUser, "drone")
g.Assert(p).Equal(fakeMembers)
g.Assert(err).Equal(nil)
})
g.It("Should get member error", func() {
r.On("GetMembers", fakeUser, "drone").Return(nil, fakeErr).Once()
r.On("GetMembers", fakeUser, "drone").Return(nil, errFake).Once()
p, err := GetMembers(c, fakeUser, "drone")
g.Assert(p == nil).IsTrue()
g.Assert(err).Equal(fakeErr)
g.Assert(err).Equal(errFake)
})
})
}