This repository has been archived on 2024-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
core-old/internal/domain/ennoblement_test.go
Dawid Wysokiński e468a1f391
All checks were successful
continuous-integration/drone/push Build is passing
feat: add a new endpoint - GET /api/v1/versions/:code/servers/:key/ennoblements (#71)
Reviewed-on: twhelp/core#71
2022-09-06 07:50:00 +00:00

51 lines
917 B
Go

package domain_test
import (
"testing"
"gitea.dwysokinski.me/twhelp/core/internal/domain"
"github.com/stretchr/testify/assert"
)
func TestNewEnnoblementSortBy(t *testing.T) {
t.Parallel()
t.Run("OK", func(t *testing.T) {
t.Parallel()
tests := []struct {
s string
output domain.EnnoblementSortBy
}{
{
s: "id",
output: domain.EnnoblementSortByID,
},
{
s: "createdAt",
output: domain.EnnoblementSortByCreatedAt,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.s, func(t *testing.T) {
t.Parallel()
res, err := domain.NewEnnoblementSortBy(tt.s)
assert.NoError(t, err)
assert.Equal(t, tt.output, res)
})
}
})
t.Run("ERR: unsupported sort by", func(t *testing.T) {
t.Parallel()
res, err := domain.NewEnnoblementSortBy("unsupported")
assert.ErrorIs(t, err, domain.ErrUnsupportedSortBy)
assert.Zero(t, res)
})
}