genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
hs_monolith/models/review_test.go

32 lines
886 B
Go

package models
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestDisplayName(t *testing.T) {
assert := assert.New(t)
r := Review{}
assert.Equal("", r.FirstName, "wrong firstname")
assert.Equal("", r.LastName, "wrong lastname")
assert.Equal("Anonymous", r.DisplayName(), "No name")
r.FirstName = "Max"
assert.Equal("Max", r.FirstName, "wrong firstname")
assert.Equal("", r.LastName, "wrong lastname")
assert.Equal("Max", r.DisplayName(), "Only Firstname")
r.LastName = "Mustermann"
assert.Equal("Max", r.FirstName, "wrong firstname")
assert.Equal("Mustermann", r.LastName, "wrong lastname")
assert.Equal("Max M.", r.DisplayName(), "Shorted Name")
r.FirstName = ""
assert.Equal("", r.FirstName, "wrong firstname")
assert.Equal("Mustermann", r.LastName, "wrong lastname")
assert.Equal("Anonymous", r.DisplayName(), "displayname: no firstname")
}