-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenqueue_test.go
More file actions
45 lines (40 loc) · 1.24 KB
/
enqueue_test.go
File metadata and controls
45 lines (40 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package resque_status_test
import (
"flag"
"github.com/Shop2market/goworker"
. "github.com/Shop2market/resque_status"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Enqueue", func() {
var redisConnection *goworker.RedisConn
BeforeEach(func() {
flag.Set("exit-on-complete", "true")
flag.Set("queues", "test_queue")
flag.Set("concurrency", "1")
flag.Set("use-number", "true")
err := goworker.Init()
if err != nil {
panic(err)
}
redisConnection, err = goworker.GetConn()
if err != nil {
panic(err)
}
redisConnection.Do("FLUSHDB")
GenerateUUID = func() string {
return "NEW_UUID"
}
})
Context("Lock", func() {
It("creates lock for a job if defined one", func() {
enq := NewEnqueuer("Job::Class", "gen", []string{"id", "year"})
params := map[string]interface{}{"id": 10, "year": "2015", "debug": true}
Expect(enq.Enqueue(params)).NotTo(HaveOccurred())
Expect(redisConnection.Do("GET", "resque:lock:Job::Class-id=10|year=2015")).To(BeEquivalentTo(`NEW_UUID`))
Expect(redisConnection.Do("EXISTS", "resque:queue:gen")).To(BeEquivalentTo(1))
Expect(redisConnection.Do("EXISTS", "resque:queues")).To(BeEquivalentTo(1))
Expect(enq.Enqueue(params)).NotTo(HaveOccurred())
})
})
})