Dawid Wysokiński
c545ebd7d7
All checks were successful
continuous-integration/drone/push Build is passing
54 lines
1.0 KiB
Go
54 lines
1.0 KiB
Go
package domain_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dwysokinski.me/twhelp/core/internal/domain"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestVillage_FullName(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
v := domain.Village{
|
|
ID: 1234,
|
|
Name: "Village",
|
|
X: 450,
|
|
Y: 450,
|
|
Continent: "K44",
|
|
}
|
|
assert.Equal(t, "Village (450|450) K44", v.FullName())
|
|
}
|
|
|
|
func TestVillageMeta_FullName(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
v := domain.Village{
|
|
ID: 1234,
|
|
Name: "Village",
|
|
X: 450,
|
|
Y: 450,
|
|
Continent: "K44",
|
|
}
|
|
meta := domain.VillageMeta{
|
|
ID: v.ID,
|
|
Name: v.Name,
|
|
X: v.X,
|
|
Y: v.Y,
|
|
Continent: v.Continent,
|
|
}
|
|
assert.Equal(t, v.FullName(), meta.FullName())
|
|
}
|
|
|
|
func TestVillageNotFoundError(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
err := domain.VillageNotFoundError{
|
|
ID: 1234,
|
|
}
|
|
var _ domain.Error = err
|
|
assert.Equal(t, "village (id=1234) not found", err.Error())
|
|
assert.Equal(t, err.Error(), err.UserError())
|
|
assert.Equal(t, domain.ErrorCodeEntityNotFound, err.Code())
|
|
}
|