-
Notifications
You must be signed in to change notification settings - Fork 2
/
error_test.go
30 lines (25 loc) · 1.08 KB
/
error_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
package qless
import (
"testing"
"github.com/gomodule/redigo/redis"
"github.com/stretchr/testify/assert"
)
func TestParseError_ReturnsCommandError(t *testing.T) {
in := redis.Error("ERR Error running script (call to f_986f06a650a32caeb31e59be88090194251ac657): @user_script:883: user_script:883: Heartbeat(): Job given out to another worker: worker-2")
err := parseError(in)
if assert.IsType(t, &CommandError{}, err) {
se := err.(*CommandError)
assert.Equal(t, "Heartbeat", se.Area)
assert.Equal(t, "Job given out to another worker: worker-2", se.Message)
}
}
func TestIsJobLost(t *testing.T) {
in := redis.Error("ERR Error running script (call to f_986f06a650a32caeb31e59be88090194251ac657): @user_script:883: user_script:883: Heartbeat(): Job given out to another worker: worker-2")
err := parseError(in)
assert.True(t, IsJobLost(err))
}
func TestIsNotJobLost(t *testing.T) {
in := redis.Error("ERR Error running script (call to f_986f06a650a32caeb31e59be88090194251ac657): @user_script:883: user_script:883: Heartbeat(): foo")
err := parseError(in)
assert.False(t, IsJobLost(err))
}