-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconnection_test.go
61 lines (45 loc) · 1.24 KB
/
connection_test.go
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package disco
import(
"testing"
"time"
"github.com/garyburd/redigo/redis"
)
// This test will attempt a connection to a Disque server specified in
// the DISQUE_NODES environmnet variable.
func TestNewConnectionToAvailableNode(t *testing.T) {
connection, err := NewConnection(1)
if err != nil {
t.Fatal(err)
}
response, err := redis.String(connection.Do("PING"))
if err != nil {
t.Fatal(err)
}
if response != "PONG" {
t.Error("Expected PONG response from Disque")
}
}
func TestAddJob(t *testing.T) {
connection, _ := NewConnection(1)
id, err := connection.AddJob("disco-test-queue", "this-is-the-payload", time.Second * 10)
if err != nil {
t.Fatal(err)
}
if id == "" {
t.Error("No job id returned from ADDJOB")
}
}
func TestConnectionGetJob(t *testing.T) {
connection, err := NewConnection(1)
connection.AddJob("disco-test-queue", "this-is-the-payload", time.Second * 10)
job, err := connection.GetJob(1, time.Second * 10, "disco-test-queue")
if err != nil {
t.Fatal(err)
}
if job.ID == "" {
t.Error("fetched jobs should always have ids")
}
if string(job.Payload) != "this-is-the-payload" {
t.Errorf("Expected payload does not match: '%v'", string(job.Payload))
}
}