2021-09-17 14:26:12 +02:00
|
|
|
package form
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewSubject(t *testing.T) {
|
|
|
|
t.Run("success", func(t *testing.T) {
|
|
|
|
var m = struct {
|
|
|
|
SubjName string `json:"Name"`
|
|
|
|
SubjAlias string `json:"Alias"`
|
|
|
|
SubjBio string `json:"Bio"`
|
|
|
|
SubjNotes string `json:"Notes"`
|
|
|
|
SubjFavorite bool `json:"Favorite"`
|
2021-10-06 15:27:17 +02:00
|
|
|
SubjHidden bool `json:"Hidden"`
|
2021-09-17 14:26:12 +02:00
|
|
|
SubjPrivate bool `json:"Private"`
|
|
|
|
SubjExcluded bool `json:"Excluded"`
|
|
|
|
}{
|
|
|
|
SubjName: "Foo",
|
|
|
|
SubjAlias: "bar",
|
|
|
|
SubjFavorite: true,
|
2021-10-06 15:27:17 +02:00
|
|
|
SubjHidden: true,
|
2021-09-17 14:26:12 +02:00
|
|
|
SubjExcluded: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
f, err := NewSubject(m)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "Foo", f.SubjName)
|
|
|
|
assert.Equal(t, "bar", f.SubjAlias)
|
|
|
|
assert.Equal(t, true, f.SubjFavorite)
|
2021-10-06 15:27:17 +02:00
|
|
|
assert.Equal(t, true, f.SubjHidden)
|
2021-09-17 14:26:12 +02:00
|
|
|
assert.Equal(t, false, f.SubjExcluded)
|
|
|
|
})
|
|
|
|
}
|