mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-23 23:58:44 +00:00
parent
627f8df98d
commit
09d5c6f011
4 changed files with 38 additions and 40 deletions
|
@ -25,21 +25,17 @@ func TestRepo(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should set Repo", func() {
|
g.It("Should set Repo", func() {
|
||||||
//err := db.SetRepoNotExists(&common.User{Name: testUser}, &common.Repo{Name: testRepo})
|
|
||||||
err := db.SetRepo(&common.Repo{FullName: testRepo})
|
err := db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
g.Assert(err).Equal(nil)
|
g.Assert(err).Equal(nil)
|
||||||
|
|
||||||
// setrepo only returns an error. Repo returns error and a structure
|
|
||||||
repo, err := db.Repo(testRepo)
|
repo, err := db.Repo(testRepo)
|
||||||
g.Assert(err).Equal(nil)
|
g.Assert(err).Equal(nil)
|
||||||
g.Assert(repo.FullName).Equal(testRepo)
|
g.Assert(repo.FullName).Equal(testRepo)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should get Repo", func() {
|
g.It("Should get Repo", func() {
|
||||||
//db.SetRepoNotExists(&common.User{Name: testUser}, &common.Repo{Name: testRepo})
|
|
||||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
|
|
||||||
// setrepo only returns an error. Repo returns error and a structure
|
|
||||||
repo, err := db.Repo(testRepo)
|
repo, err := db.Repo(testRepo)
|
||||||
g.Assert(err).Equal(nil)
|
g.Assert(err).Equal(nil)
|
||||||
g.Assert(repo.FullName).Equal(testRepo)
|
g.Assert(repo.FullName).Equal(testRepo)
|
||||||
|
@ -47,8 +43,7 @@ func TestRepo(t *testing.T) {
|
||||||
|
|
||||||
g.It("Should del Repo", func() {
|
g.It("Should del Repo", func() {
|
||||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
// setrepo only returns an error. Repo returns error and a structure
|
|
||||||
//repo, err := db.Repo(testRepo)
|
|
||||||
db.Repo(testRepo)
|
db.Repo(testRepo)
|
||||||
err_ := db.DelRepo((&common.Repo{FullName: testRepo}))
|
err_ := db.DelRepo((&common.Repo{FullName: testRepo}))
|
||||||
g.Assert(err_).Equal(nil)
|
g.Assert(err_).Equal(nil)
|
||||||
|
@ -57,22 +52,19 @@ func TestRepo(t *testing.T) {
|
||||||
g.It("Should get RepoList", func() {
|
g.It("Should get RepoList", func() {
|
||||||
db.SetRepoNotExists(&common.User{Login: testUser}, &common.Repo{FullName: testRepo})
|
db.SetRepoNotExists(&common.User{Login: testUser}, &common.Repo{FullName: testRepo})
|
||||||
db.SetRepoNotExists(&common.User{Login: testUser}, &common.Repo{FullName: testRepo2})
|
db.SetRepoNotExists(&common.User{Login: testUser}, &common.Repo{FullName: testRepo2})
|
||||||
//db.SetRepo(&common.Repo{FullName: testRepo})
|
|
||||||
//db.SetRepo(&common.Repo{FullName: testRepo2})
|
|
||||||
repos, err := db.RepoList(testUser)
|
repos, err := db.RepoList(testUser)
|
||||||
g.Assert(err).Equal(nil)
|
g.Assert(err).Equal(nil)
|
||||||
g.Assert(len(repos)).Equal(2)
|
g.Assert(len(repos)).Equal(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should set RepoParams", func() {
|
g.It("Should set RepoParams", func() {
|
||||||
//db.SetRepoNotExists(&common.User{Name: testUser}, &common.Repo{Name: testRepo})
|
|
||||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
err := db.SetRepoParams(testRepo, map[string]string{"A": "Alpha"})
|
err := db.SetRepoParams(testRepo, map[string]string{"A": "Alpha"})
|
||||||
g.Assert(err).Equal(nil)
|
g.Assert(err).Equal(nil)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should get RepoParams", func() {
|
g.It("Should get RepoParams", func() {
|
||||||
//db.SetRepoNotExists(&common.User{Name: testUser}, &common.Repo{Name: testRepo})
|
|
||||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
err := db.SetRepoParams(testRepo, map[string]string{"A": "Alpha", "B": "Beta"})
|
err := db.SetRepoParams(testRepo, map[string]string{"A": "Alpha", "B": "Beta"})
|
||||||
params, err := db.RepoParams(testRepo)
|
params, err := db.RepoParams(testRepo)
|
||||||
|
@ -89,12 +81,12 @@ func TestRepo(t *testing.T) {
|
||||||
g.Assert(err).Equal(nil)
|
g.Assert(err).Equal(nil)
|
||||||
// We should get ErrConflict now, trying to add the same repo again.
|
// We should get ErrConflict now, trying to add the same repo again.
|
||||||
err_ := db.SetRepoNotExists(&common.User{Login: testUser}, &common.Repo{FullName: testRepo})
|
err_ := db.SetRepoNotExists(&common.User{Login: testUser}, &common.Repo{FullName: testRepo})
|
||||||
g.Assert(err_ == nil).IsFalse() // we should get (ErrConflict)
|
g.Assert(err_).Equal(ErrKeyExists)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should set RepoKeypair", func() {
|
g.It("Should set RepoKeypair", func() {
|
||||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
//err := db.SetRepoKeypair(testRepo, &common.Keypair{Private: []byte("A"), Public: []byte("Alpha")})
|
|
||||||
err := db.SetRepoKeypair(testRepo, &common.Keypair{Private: "A", Public: "Alpha"})
|
err := db.SetRepoKeypair(testRepo, &common.Keypair{Private: "A", Public: "Alpha"})
|
||||||
g.Assert(err).Equal(nil)
|
g.Assert(err).Equal(nil)
|
||||||
})
|
})
|
||||||
|
@ -102,7 +94,7 @@ func TestRepo(t *testing.T) {
|
||||||
g.It("Should get RepoKeypair", func() {
|
g.It("Should get RepoKeypair", func() {
|
||||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
err := db.SetRepoKeypair(testRepo, &common.Keypair{Private: "A", Public: "Alpha"})
|
err := db.SetRepoKeypair(testRepo, &common.Keypair{Private: "A", Public: "Alpha"})
|
||||||
//g.Assert(err).Equal(nil)
|
|
||||||
keypair, err := db.RepoKeypair(testRepo)
|
keypair, err := db.RepoKeypair(testRepo)
|
||||||
g.Assert(err).Equal(nil)
|
g.Assert(err).Equal(nil)
|
||||||
g.Assert(keypair.Public).Equal("Alpha")
|
g.Assert(keypair.Public).Equal("Alpha")
|
||||||
|
@ -128,7 +120,7 @@ func TestRepo(t *testing.T) {
|
||||||
db.SetSubscriber(testUser, testRepo)
|
db.SetSubscriber(testUser, testRepo)
|
||||||
err := db.DelSubscriber(testUser, testRepo)
|
err := db.DelSubscriber(testUser, testRepo)
|
||||||
g.Assert(err).Equal(nil)
|
g.Assert(err).Equal(nil)
|
||||||
//
|
|
||||||
subscribed, err := db.Subscribed(testUser, testRepo)
|
subscribed, err := db.Subscribed(testUser, testRepo)
|
||||||
g.Assert(subscribed).Equal(false)
|
g.Assert(subscribed).Equal(false)
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,18 @@ package bolt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"github.com/boltdb/bolt"
|
||||||
|
//"github.com/drone/drone/common"
|
||||||
"io"
|
"io"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/boltdb/bolt"
|
|
||||||
"github.com/drone/drone/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
Brad Rydzewski1:00 PM
|
||||||
|
the `Task`, `TaskList` and `SetTask` are deprecated and can be probably be removed.
|
||||||
|
I just need to make sure we aren't still using those functions anywhere else in the code
|
||||||
|
*/
|
||||||
|
/*
|
||||||
// GetTask gets the task at index N for the named
|
// GetTask gets the task at index N for the named
|
||||||
// repository and build number.
|
// repository and build number.
|
||||||
func (db *DB) Task(repo string, build int, task int) (*common.Task, error) {
|
func (db *DB) Task(repo string, build int, task int) (*common.Task, error) {
|
||||||
|
@ -63,6 +68,7 @@ func (db *DB) SetTask(repo string, build int, task *common.Task) error {
|
||||||
return update(t, bucketBuildTasks, key, task)
|
return update(t, bucketBuildTasks, key, task)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// SetLogs inserts or updates a task logs for the
|
// SetLogs inserts or updates a task logs for the
|
||||||
// named repository and build number.
|
// named repository and build number.
|
||||||
|
|
|
@ -15,7 +15,7 @@ func TestTask(t *testing.T) {
|
||||||
testRepo := "github.com/octopod/hq"
|
testRepo := "github.com/octopod/hq"
|
||||||
testBuild := 1
|
testBuild := 1
|
||||||
testTask := 0
|
testTask := 0
|
||||||
testTask2 := 1
|
//testTask2 := 1
|
||||||
testLogInfo := []byte("Log Info for SetLogs()")
|
testLogInfo := []byte("Log Info for SetLogs()")
|
||||||
var db *DB // Temp database
|
var db *DB // Temp database
|
||||||
|
|
||||||
|
@ -28,21 +28,6 @@ func TestTask(t *testing.T) {
|
||||||
os.Remove(db.Path())
|
os.Remove(db.Path())
|
||||||
})
|
})
|
||||||
|
|
||||||
g.It("Should set Task", func() {
|
|
||||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
|
||||||
err := db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
|
||||||
g.Assert(err).Equal(nil)
|
|
||||||
})
|
|
||||||
|
|
||||||
g.It("Should get Task", func() {
|
|
||||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
|
||||||
db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
|
||||||
//
|
|
||||||
task, err := db.Task(testRepo, testBuild, testTask)
|
|
||||||
g.Assert(err).Equal(nil)
|
|
||||||
g.Assert(task.Number).Equal(testTask)
|
|
||||||
})
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Brad Rydzewski1:00 PM
|
Brad Rydzewski1:00 PM
|
||||||
the `Task`, `TaskList` and `SetTask` are deprecated and can be probably be removed.
|
the `Task`, `TaskList` and `SetTask` are deprecated and can be probably be removed.
|
||||||
|
@ -63,12 +48,27 @@ func TestTask(t *testing.T) {
|
||||||
//g.Assert(err).Equal(nil)
|
//g.Assert(err).Equal(nil)
|
||||||
//g.Assert(len(tasks)).Equal(2)
|
//g.Assert(len(tasks)).Equal(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
g.It("Should set Task", func() {
|
||||||
|
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
|
err := db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
||||||
|
g.Assert(err).Equal(nil)
|
||||||
|
})
|
||||||
|
|
||||||
|
g.It("Should get Task", func() {
|
||||||
|
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
|
db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
||||||
|
//
|
||||||
|
task, err := db.Task(testRepo, testBuild, testTask)
|
||||||
|
g.Assert(err).Equal(nil)
|
||||||
|
g.Assert(task.Number).Equal(testTask)
|
||||||
|
})
|
||||||
*/
|
*/
|
||||||
|
|
||||||
g.It("Should set Logs", func() {
|
g.It("Should set Logs", func() {
|
||||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
//db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
||||||
db.SetTask(testRepo, testBuild, &common.Task{Number: testTask2})
|
//db.SetTask(testRepo, testBuild, &common.Task{Number: testTask2})
|
||||||
//
|
//
|
||||||
err := db.SetLogs(testRepo, testBuild, testTask, testLogInfo)
|
err := db.SetLogs(testRepo, testBuild, testTask, testLogInfo)
|
||||||
g.Assert(err).Equal(nil)
|
g.Assert(err).Equal(nil)
|
||||||
|
@ -76,8 +76,8 @@ func TestTask(t *testing.T) {
|
||||||
|
|
||||||
g.It("Should LogReader", func() {
|
g.It("Should LogReader", func() {
|
||||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||||
db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
//db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
||||||
db.SetTask(testRepo, testBuild, &common.Task{Number: testTask2})
|
//db.SetTask(testRepo, testBuild, &common.Task{Number: testTask2})
|
||||||
db.SetLogs(testRepo, testBuild, testTask, testLogInfo)
|
db.SetLogs(testRepo, testBuild, testTask, testLogInfo)
|
||||||
//
|
//
|
||||||
buf, err_ := db.LogReader(testRepo, testBuild, testTask)
|
buf, err_ := db.LogReader(testRepo, testBuild, testTask)
|
||||||
|
|
|
@ -121,15 +121,15 @@ type Datastore interface {
|
||||||
|
|
||||||
// GetTask gets the task at index N for the named
|
// GetTask gets the task at index N for the named
|
||||||
// repository and build number.
|
// repository and build number.
|
||||||
Task(string, int, int) (*common.Task, error)
|
//Task(string, int, int) (*common.Task, error)
|
||||||
|
|
||||||
// TaskList gets all tasks for the named repository
|
// TaskList gets all tasks for the named repository
|
||||||
// and build number.
|
// and build number.
|
||||||
TaskList(string, int) ([]*common.Task, error)
|
//TaskList(string, int) ([]*common.Task, error)
|
||||||
|
|
||||||
// SetTask inserts or updates a task for the named
|
// SetTask inserts or updates a task for the named
|
||||||
// repository and build number.
|
// repository and build number.
|
||||||
SetTask(string, int, *common.Task) error
|
//SetTask(string, int, *common.Task) error
|
||||||
|
|
||||||
// LogReader gets the task logs at index N for
|
// LogReader gets the task logs at index N for
|
||||||
// the named repository and build number.
|
// the named repository and build number.
|
||||||
|
|
Loading…
Reference in a new issue