git-bug/identity/bare_test.go

37 lines
664 B
Go
Raw Normal View History

2019-01-19 21:23:31 +03:00
package identity
import (
"encoding/json"
2019-01-19 21:23:31 +03:00
"testing"
"github.com/stretchr/testify/assert"
"github.com/MichaelMure/git-bug/entity"
2019-01-19 21:23:31 +03:00
)
func TestBare_Id(t *testing.T) {
i := NewBare("name", "email")
id := i.Id()
expected := entity.Id("e18b853fbd89d5d40ca24811539c9a800c705abd9232f396954e8ca8bb63fa8a")
assert.Equal(t, expected, id)
2019-01-19 21:23:31 +03:00
}
func TestBareSerialize(t *testing.T) {
before := &Bare{
email: "email",
name: "name",
avatarUrl: "avatar",
}
data, err := json.Marshal(before)
assert.NoError(t, err)
var after Bare
err = json.Unmarshal(data, &after)
assert.NoError(t, err)
before.id = after.id
assert.Equal(t, before, &after)
}