2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-12 09:14:16 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package satellitedb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-05-19 16:10:46 +01:00
|
|
|
"github.com/lib/pq"
|
2018-11-12 09:14:16 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2019-05-19 16:10:46 +01:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/storj"
|
|
|
|
"storj.io/common/testrand"
|
2018-11-12 09:14:16 +00:00
|
|
|
)
|
|
|
|
|
2019-05-19 16:10:46 +01:00
|
|
|
func TestPostgresNodeIDsArray(t *testing.T) {
|
|
|
|
ids := make(storj.NodeIDList, 10)
|
|
|
|
for i := range ids {
|
2019-06-26 11:38:51 +01:00
|
|
|
ids[i] = testrand.NodeID()
|
2019-05-19 16:10:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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)))
|
|
|
|
}
|