2a0c4e60d2
* preparing for use of `customtype` gogo extension with `NodeID` type * review changes * preparing for use of `customtype` gogo extension with `NodeID` type * review changes * wip * tests passing * wip fixing tests * more wip test fixing * remove NodeIDList from proto files * linter fixes * linter fixes * linter/review fixes * more freaking linter fixes * omg just kill me - linterrrrrrrr * travis linter, i will muder you and your family in your sleep * goimports everything - burn in hell travis * goimports update * go mod tidy
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package testsuite
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"storj.io/storj/storage"
|
|
)
|
|
|
|
// RunQueueTests runs common storage.Queue tests
|
|
func RunQueueTests(t *testing.T, q storage.Queue) {
|
|
t.Run("basic", func(t *testing.T) { testBasic(t, q) })
|
|
}
|
|
|
|
func testBasic(t *testing.T, q storage.Queue) {
|
|
err := q.Enqueue(storage.Value("hello world"))
|
|
assert.NoError(t, err)
|
|
err = q.Enqueue(storage.Value("Привіт, світе"))
|
|
assert.NoError(t, err)
|
|
err = q.Enqueue(storage.Value([]byte{0, 0, 0, 0, 255, 255, 255, 255}))
|
|
assert.NoError(t, err)
|
|
list, err := q.Peekqueue(100)
|
|
assert.NotNil(t, list)
|
|
assert.NoError(t, err)
|
|
out, err := q.Dequeue()
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, out, storage.Value("hello world"))
|
|
out, err = q.Dequeue()
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, out, storage.Value("Привіт, світе"))
|
|
out, err = q.Dequeue()
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, out, storage.Value([]byte{0, 0, 0, 0, 255, 255, 255, 255}))
|
|
out, err = q.Dequeue()
|
|
assert.Nil(t, out)
|
|
assert.Error(t, err)
|
|
}
|