Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: move nil test from pop to push
  • Loading branch information
plyr4 committed Feb 27, 2023
commit 382d555864ebbaeeec199ff67429b8a2498ad741
23 changes: 0 additions & 23 deletions queue/redis/pop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,6 @@ func TestRedis_Pop(t *testing.T) {
// overwrite channel to be invalid
badChannel.config.Channels = nil

// push nothing to queue
// err = badChannel.Redis.RPush(context.Background(), "vela", nil).Err()
// if err != nil {
// t.Errorf("unable to push item to queue: %v", err)
// }

// setup badItem redis mock
// badItem, err := NewTest("vela")
// if err != nil {
// t.Errorf("unable to create queue service: %v", err)
// }

// push nothing to queue
// err = badItem.Redis.RPush(context.Background(), "vela", nil).Err()
// if err != nil {
// t.Errorf("unable to push item to queue: %v", err)
// }

// setup tests
tests := []struct {
failure bool
Expand All @@ -97,11 +79,6 @@ func TestRedis_Pop(t *testing.T) {
redis: badChannel,
want: nil,
},
// {
// failure: true,
// redis: badItem,
// want: nil,
// },
}

// run tests
Expand Down
17 changes: 15 additions & 2 deletions queue/redis/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestRedis_Push(t *testing.T) {
}

// setup queue item
bytes, err := json.Marshal(_item)
_bytes, err := json.Marshal(_item)
if err != nil {
t.Errorf("unable to marshal queue item: %v", err)
}
Expand All @@ -34,20 +34,33 @@ func TestRedis_Push(t *testing.T) {
t.Errorf("unable to create queue service: %v", err)
}

// setup redis mock
badItem, err := NewTest("vela")
if err != nil {
t.Errorf("unable to create queue service: %v", err)
}

// setup tests
tests := []struct {
failure bool
redis *client
bytes []byte
}{
{
failure: false,
redis: _redis,
bytes: _bytes,
},
{
failure: true,
redis: badItem,
bytes: nil,
},
}

// run tests
for _, test := range tests {
err := _redis.Push(context.Background(), "vela", bytes)
err := test.redis.Push(context.Background(), "vela", test.bytes)

if test.failure {
if err == nil {
Expand Down