woodpecker/datastore/builtin/task_test.go
Daniel Oliveira ba159976a0 Fixing TODO comments in code /cc @oliveiradan
1. server/login.go:49 (// TODO(bradrydzewski) return an error message instead). Added error message if authorization fails.
2. server/repos.go:178 (TODO(bradrydzewski) verify repo not exists). Added a checking for the repo and return an error in case it does not exist.
3. server/queue.go:170:  // TODO (bradrydzewski) change this interface to accept an io.Reader. All references to the API change been in question SetLogs() have been modified.
4. remote/github/github.go:106  // Fixed a crash in case *repo_.Language is nil , when de-referencing it. This could happen when a repo only has a readme, so github hasn't set the language yet.
5. ./server/queue.go:170:  // TODO (bradrydzewski) change this interface to accept an io.Reader. All references to the API change been in question SetLogs() have been modified.
6. .remote/github/github.go:106  // Fixed a crash in case *repo_.Language is nil , when de-referencing it. This could happen when a repo only has a readme, so github hasn't set the language yet.
2015-05-08 10:47:40 -06:00

47 lines
1.1 KiB
Go

package builtin
import (
"bytes"
"github.com/drone/drone/common"
. "github.com/franela/goblin"
"io/ioutil"
"os"
"testing"
)
func TestTask(t *testing.T) {
g := Goblin(t)
g.Describe("Tasks", func() {
testRepo := "octopod/hq"
testBuild := 1
testTask := 0
testLogInfo := []byte("Log Info for SetLogs()")
var db *DB // Temp database
// create a new database before each unit
// test and destroy afterwards.
g.BeforeEach(func() {
db = Must("/tmp/drone.test.db")
})
g.AfterEach(func() {
os.Remove(db.Path())
})
g.It("Should set Logs", func() {
db.SetRepo(&common.Repo{FullName: testRepo})
err := db.SetLogs(testRepo, testBuild, testTask, (bytes.NewBuffer(testLogInfo)))
g.Assert(err).Equal(nil)
})
g.It("Should get logs", func() {
db.SetRepo(&common.Repo{FullName: testRepo})
db.SetLogs(testRepo, testBuild, testTask, (bytes.NewBuffer(testLogInfo)))
buf, err := db.LogReader(testRepo, testBuild, testTask)
g.Assert(err).Equal(nil)
logInfo, err := ioutil.ReadAll(buf)
g.Assert(logInfo).Equal(testLogInfo)
})
})
}