From 340c1cfbfa1c07a6049255863578672af02c531e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Lafoucrie=CC=80re?= Date: Wed, 1 Jan 2014 21:36:26 +0100 Subject: [PATCH 1/2] Export the workers list but don't expose workerFuncs --- workers.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/workers.go b/workers.go index e33035f..45a0ce8 100644 --- a/workers.go +++ b/workers.go @@ -15,3 +15,11 @@ func init() { func Register(class string, worker workerFunc) { workers[class] = worker } + +func Workers() []string { + mk := make([]string, len(workers)) + for k, _ := range workers { + mk = append(mk, k) + } + return mk +} From 47c41eee3d1697086b36351383677e4f67ab55a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Lafoucrie=CC=80re?= Date: Wed, 1 Jan 2014 21:39:35 +0100 Subject: [PATCH 2/2] Add Workers test --- workers_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 workers_test.go diff --git a/workers_test.go b/workers_test.go new file mode 100644 index 0000000..5860a0c --- /dev/null +++ b/workers_test.go @@ -0,0 +1,18 @@ +package goworker + +import ( + "reflect" + "testing" +) + +func TestWorkers(t *testing.T) { + Register("SomeJob", fakePerformer) + workers := Workers() + if reflect.DeepEqual(workers, []string{"SomeJob"}) { + t.Error("Excepted worker \"SomeJob\" to be registered") + } +} + +func fakePerformer(queue string, args ...interface{}) error { + return nil +}