2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-08 14:19:42 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package satellitedb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2018-11-30 13:40:13 +00:00
|
|
|
|
2019-01-16 20:23:28 +00:00
|
|
|
dbx "storj.io/storj/satellite/satellitedb/dbx"
|
2018-11-08 14:19:42 +00:00
|
|
|
)
|
|
|
|
|
2018-11-09 12:05:24 +00:00
|
|
|
func TestUserFromDbx(t *testing.T) {
|
2018-11-08 14:19:42 +00:00
|
|
|
t.Run("can't create dbo from nil dbx model", func(t *testing.T) {
|
2019-06-04 12:55:38 +01:00
|
|
|
user, err := userFromDBX(ctx, nil)
|
2018-11-08 14:19:42 +00:00
|
|
|
assert.Nil(t, user)
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
|
2018-11-09 12:05:24 +00:00
|
|
|
t.Run("can't create dbo from dbx model with invalid ID", func(t *testing.T) {
|
2018-11-08 14:19:42 +00:00
|
|
|
dbxUser := dbx.User{
|
2018-11-09 12:05:24 +00:00
|
|
|
Id: []byte("qweqwe"),
|
2019-03-27 12:33:32 +00:00
|
|
|
FullName: "Very long full name",
|
|
|
|
ShortName: nil,
|
2019-02-11 10:33:56 +00:00
|
|
|
Email: "some@email.com",
|
2018-11-08 14:19:42 +00:00
|
|
|
PasswordHash: []byte("ihqerfgnu238723huagsd"),
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
}
|
|
|
|
|
2019-06-04 12:55:38 +01:00
|
|
|
user, err := userFromDBX(ctx, &dbxUser)
|
2018-11-08 14:19:42 +00:00
|
|
|
|
|
|
|
assert.Nil(t, user)
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
}
|