diff options
author | Aleksander Mistewicz <a.mistewicz@samsung.com> | 2017-06-08 17:28:51 +0200 |
---|---|---|
committer | Maciej Wereski <m.wereski@partner.samsung.com> | 2017-10-04 10:18:44 +0200 |
commit | 256693fe3ea79184d58b36b92865ebd6ed7bc9dd (patch) | |
tree | 6a3c27d5d255c584926252e2972e36584729b1b0 /workers | |
parent | 84488cfab4208bf6244283db4963a2053b087d43 (diff) | |
download | boruta-256693fe3ea79184d58b36b92865ebd6ed7bc9dd.tar.gz boruta-256693fe3ea79184d58b36b92865ebd6ed7bc9dd.tar.bz2 boruta-256693fe3ea79184d58b36b92865ebd6ed7bc9dd.zip |
Implement get information about the Worker
In order to avoid listing workers when information about only one is
needed, a convenience function has been added. It is faster and
guarantees that a single structure will be returned or an error.
workers/workers_test.go has been removed as all functions has been
implemented.
Change-Id: I0dfaccc4c55bdb30c5875de06db9d3b23b2345b2
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Reviewed-on: https://mcdsrvbld02.digital.local/review/49062
Reviewed-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Tested-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Reviewed-by: Maciej Wereski <m.wereski@partner.samsung.com>
Tested-by: Maciej Wereski <m.wereski@partner.samsung.com>
Diffstat (limited to 'workers')
-rw-r--r-- | workers/worker_list_test.go | 14 | ||||
-rw-r--r-- | workers/workers.go | 6 | ||||
-rw-r--r-- | workers/workers_test.go | 43 |
3 files changed, 19 insertions, 44 deletions
diff --git a/workers/worker_list_test.go b/workers/worker_list_test.go index d7b2500..f7a3c62 100644 --- a/workers/worker_list_test.go +++ b/workers/worker_list_test.go @@ -432,5 +432,19 @@ var _ = Describe("WorkerList", func() { refWorkerList[2], refWorkerList[3], refWorkerList[5]}) }) }) + + Describe("GetWorkerInfo", func() { + It("should fail to GetWorkerInfo of nonexistent worker", func() { + uuid := randomUUID() + _, err := wl.GetWorkerInfo(uuid) + Expect(err).To(Equal(ErrWorkerNotFound)) + }) + + It("should work to GetWorkerInfo", func() { + workerInfo, err := wl.GetWorkerInfo(worker) + Expect(err).ToNot(HaveOccurred()) + Expect(workerInfo).To(Equal(*wl.workers[worker])) + }) + }) }) }) diff --git a/workers/workers.go b/workers/workers.go index 1192b28..e3987e0 100644 --- a/workers/workers.go +++ b/workers/workers.go @@ -217,5 +217,9 @@ func (wl *WorkerList) ListWorkers(groups Groups, caps Capabilities) ([]WorkerInf // GetWorkerInfo is an implementation of GetWorkerInfo from Workers interface. func (wl *WorkerList) GetWorkerInfo(uuid WorkerUUID) (WorkerInfo, error) { - return WorkerInfo{}, ErrNotImplemented + worker, ok := wl.workers[uuid] + if !ok { + return WorkerInfo{}, ErrWorkerNotFound + } + return *worker, nil } diff --git a/workers/workers_test.go b/workers/workers_test.go deleted file mode 100644 index cf3c5c3..0000000 --- a/workers/workers_test.go +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package workers_test - -import ( - . "git.tizen.org/tools/boruta" - . "git.tizen.org/tools/boruta/workers" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("WorkerList", func() { - var wl *WorkerList - BeforeEach(func() { - wl = NewWorkerList() - }) - - It("should return ErrNotImplemented", func() { - var ( - err error - uuid WorkerUUID = "" - ) - - By("GetWorkerInfo") - _, err = wl.GetWorkerInfo(uuid) - Expect(err).To(Equal(ErrNotImplemented)) - }) -}) |