storj/satellite/satellitedb/util_test.go
Egon Elbre 52cefb816c satellite/satellitedb: add utility for converting slices
Change-Id: I2654a9ef7c58016bd5af923c66f5f31819ab9b9d
2023-06-05 14:12:02 +00:00

24 lines
496 B
Go

// Copyright (C) 2023 Storj Labs, Inc.
// See LICENSE for copying information.
package satellitedb
import (
"strconv"
"testing"
"github.com/stretchr/testify/require"
)
func TestConvertSlice(t *testing.T) {
good := []string{"1", "2", "3", "4"}
out, err := convertSlice(good, strconv.Atoi)
require.NoError(t, err)
require.Equal(t, []int{1, 2, 3, 4}, out)
bad := []string{"1", "bad", "asdf", ""}
out, err = convertSlice(bad, strconv.Atoi)
require.Error(t, err)
require.Nil(t, out)
}