storj/satellite/satellitedb/utils_test.go
Egon Elbre 6615ecc9b6 common: separate repository
Change-Id: Ibb89c42060450e3839481a7e495bbe3ad940610a
2019-12-27 14:11:15 +02:00

31 lines
663 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/common/storj"
"storj.io/common/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)))
}