}
})
})
+
+ Describe("SetGroups", func() {
+ It("should fail to SetGroup of nonexistent worker", func() {
+ uuid := randomUUID()
+ err := wl.SetGroups(uuid, nil)
+ Expect(err).To(Equal(ErrWorkerNotFound))
+ })
+
+ It("should work to SetGroup", func() {
+ var group Groups = []Group{
+ Group("group1"),
+ }
+
+ By("setting it")
+ err := wl.SetGroups(worker, group)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(wl.workers[worker].Groups).To(Equal(group))
+
+ By("setting it to nil")
+ err = wl.SetGroups(worker, nil)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(wl.workers[worker].Groups).To(BeNil())
+ })
+ })
})
})
// SetGroups is an implementation of SetGroups from Workers interface.
func (wl *WorkerList) SetGroups(uuid WorkerUUID, groups Groups) error {
- return ErrNotImplemented
+ worker, ok := wl.workers[uuid]
+ if !ok {
+ return ErrWorkerNotFound
+ }
+ worker.Groups = groups
+ return nil
}
// Deregister is an implementation of Deregister from Workers interface.
groups Groups = nil
)
- By("SetGroups")
- err = wl.SetGroups(uuid, groups)
- Expect(err).To(Equal(ErrNotImplemented))
-
By("ListWorkers")
_, err = wl.ListWorkers(groups, caps)
Expect(err).To(Equal(ErrNotImplemented))