From 3f2d72daf0d3e2c444c417a2dffda8524332be77 Mon Sep 17 00:00:00 2001 From: Daniel Oliveira Date: Mon, 20 Apr 2015 19:57:50 -0600 Subject: [PATCH] Code changes related to PR #986 and Issue #984. Comments deleted --- datastore/bolt/task.go | 63 ------------------------------------- datastore/bolt/task_test.go | 37 ---------------------- datastore/datastore.go | 12 ------- 3 files changed, 112 deletions(-) diff --git a/datastore/bolt/task.go b/datastore/bolt/task.go index ff09fcf13..ae23a8c39 100644 --- a/datastore/bolt/task.go +++ b/datastore/bolt/task.go @@ -3,73 +3,10 @@ package bolt import ( "bytes" "github.com/boltdb/bolt" - //"github.com/drone/drone/common" "io" "strconv" ) -/* - 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 -// repository and build number. -func (db *DB) Task(repo string, build int, task int) (*common.Task, error) { - key := []byte(repo + "/" + strconv.Itoa(build) + "/" + strconv.Itoa(task)) - task_ := &common.Task{} - err := db.View(func(t *bolt.Tx) error { - return get(t, bucketBuildTasks, key, task_) - }) - return task_, err -} - -// TaskList gets all tasks for the named repository -// and build number. -func (db *DB) TaskList(repo string, build int) ([]*common.Task, error) { - // fetch the build so that we can get the - // number of child tasks. - build_, err := db.Build(repo, build) - if err != nil { - return nil, err - } - - t, err := db.Begin(false) - if err != nil { - return nil, err - } - defer t.Rollback() - - // based on the number of child tasks, incrment - // and loop to get each task from the bucket. - tasks := []*common.Task{} - for i := 1; i <= build_.Number; i++ { - key := []byte(repo + "/" + strconv.Itoa(build) + "/" + strconv.Itoa(i)) - raw := t.Bucket(bucketBuildTasks).Get(key) - if raw == nil { - return nil, ErrKeyNotFound - } - task := &common.Task{} - err := decode(raw, task) - if err != nil { - return nil, err - } - tasks = append(tasks, task) - } - return tasks, nil -} - -// SetTask inserts or updates a task for the named -// repository and build number. -func (db *DB) SetTask(repo string, build int, task *common.Task) error { - key := []byte(repo + "/" + strconv.Itoa(build) + "/" + strconv.Itoa(task.Number)) - return db.Update(func(t *bolt.Tx) error { - return update(t, bucketBuildTasks, key, task) - }) -} -*/ - // SetLogs inserts or updates a task logs for the // named repository and build number. func (db *DB) SetLogs(repo string, build int, task int, log []byte) error { diff --git a/datastore/bolt/task_test.go b/datastore/bolt/task_test.go index 573c75570..87d8905e3 100644 --- a/datastore/bolt/task_test.go +++ b/datastore/bolt/task_test.go @@ -28,43 +28,6 @@ func TestTask(t *testing.T) { os.Remove(db.Path()) }) - /* - 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 - */ - /* - g.It("Should get TaskList", func() { - db.SetRepo(&common.Repo{FullName: testRepo}) - //db.SetRepoNotExists(&common.User{Login: testUser}, &common.Repo{FullName: testRepo}) - err := db.SetTask(testRepo, testBuild, &common.Task{Number: testTask}) - g.Assert(err).Equal(nil) - err_ := db.SetTask(testRepo, testBuild, &common.Task{Number: testTask2}) - g.Assert(err_).Equal(nil) - // - tasks, err := db.TaskList(testRepo, testBuild) - // We seem to have an issue here. TaskList doesn't seem to be returning - // All the tasks added to to repo/build. So commenting these for now. - //g.Assert(err).Equal(nil) - //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() { db.SetRepo(&common.Repo{FullName: testRepo}) //db.SetTask(testRepo, testBuild, &common.Task{Number: testTask}) diff --git a/datastore/datastore.go b/datastore/datastore.go index 19631da0f..32d744984 100644 --- a/datastore/datastore.go +++ b/datastore/datastore.go @@ -119,18 +119,6 @@ type Datastore interface { // exists an error is returned. SetStatus(string, int, *common.Status) error - // GetTask gets the task at index N for the named - // repository and build number. - //Task(string, int, int) (*common.Task, error) - - // TaskList gets all tasks for the named repository - // and build number. - //TaskList(string, int) ([]*common.Task, error) - - // SetTask inserts or updates a task for the named - // repository and build number. - //SetTask(string, int, *common.Task) error - // LogReader gets the task logs at index N for // the named repository and build number. LogReader(string, int, int) (io.Reader, error)