storj/private/dbutil/uuid_test.go
Egon Elbre 0a69da4ff1 all: switch to storj.io/common/uuid
Change-Id: I178a0a8dac691e57bce317b91411292fb3c40c9f
2020-03-31 19:16:41 +03:00

32 lines
569 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package dbutil
import (
"testing"
"github.com/stretchr/testify/assert"
"storj.io/common/testrand"
)
func TestBytesToUUID(t *testing.T) {
t.Run("Invalid input", func(t *testing.T) {
str := "not UUID string"
bytes := []byte(str)
_, err := BytesToUUID(bytes)
assert.NotNil(t, err)
assert.Error(t, err)
})
t.Run("Valid input", func(t *testing.T) {
id := testrand.UUID2()
result, err := BytesToUUID(id[:])
assert.NoError(t, err)
assert.Equal(t, result, id)
})
}