1
0
Fork 0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-25 18:00:30 +00:00
woodpecker/pkg/store/builtin/star_test.go

61 lines
1.4 KiB
Go
Raw Normal View History

package builtin
import (
"testing"
2015-05-22 18:37:40 +00:00
"github.com/drone/drone/Godeps/_workspace/src/github.com/franela/goblin"
2015-06-14 00:51:55 +00:00
"github.com/drone/drone/pkg/types"
)
func TestStarstore(t *testing.T) {
db := mustConnectTest()
ss := NewStarstore(db)
defer db.Close()
g := goblin.Goblin(t)
g.Describe("Starstore", func() {
// before each test be sure to purge the package
// table data from the database.
g.BeforeEach(func() {
db.Exec("DELETE FROM stars")
})
g.It("Should Add a Star", func() {
2015-06-14 00:51:55 +00:00
user := types.User{ID: 1}
repo := types.Repo{ID: 2}
err := ss.AddStar(&user, &repo)
g.Assert(err == nil).IsTrue()
})
g.It("Should Get Starred", func() {
2015-06-14 00:51:55 +00:00
user := types.User{ID: 1}
repo := types.Repo{ID: 2}
ss.AddStar(&user, &repo)
ok, err := ss.Starred(&user, &repo)
g.Assert(err == nil).IsTrue()
g.Assert(ok).IsTrue()
})
g.It("Should Not Get Starred", func() {
2015-06-14 00:51:55 +00:00
user := types.User{ID: 1}
repo := types.Repo{ID: 2}
ok, err := ss.Starred(&user, &repo)
g.Assert(err != nil).IsTrue()
g.Assert(ok).IsFalse()
})
g.It("Should Del a Star", func() {
2015-06-14 00:51:55 +00:00
user := types.User{ID: 1}
repo := types.Repo{ID: 2}
ss.AddStar(&user, &repo)
_, err1 := ss.Starred(&user, &repo)
err2 := ss.DelStar(&user, &repo)
_, err3 := ss.Starred(&user, &repo)
g.Assert(err1 == nil).IsTrue()
g.Assert(err2 == nil).IsTrue()
g.Assert(err3 == nil).IsFalse()
})
})
}