storj/satellite/satellitedb/utils_test.go

31 lines
673 B
Go
Raw Normal View History

2019-01-24 16:26:36 +00:00
// 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)))
}