31 lines
673 B
Go
31 lines
673 B
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package satellitedb
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/lib/pq"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"storj.io/storj/pkg/storj"
|
|
"storj.io/storj/private/testrand"
|
|
)
|
|
|
|
func TestPostgresNodeIDsArray(t *testing.T) {
|
|
ids := make(storj.NodeIDList, 10)
|
|
for i := range ids {
|
|
ids[i] = testrand.NodeID()
|
|
}
|
|
|
|
got, err := postgresNodeIDList(ids).Value() // returns a []byte
|
|
require.NoError(t, err)
|
|
|
|
expected, err := pq.ByteaArray(ids.Bytes()).Value() // returns a string
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, expected.(string), string(got.([]byte)))
|
|
}
|