43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
package lishwist_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
lishwist "lishwist/core"
|
|
"lishwist/core/internal/fixtures"
|
|
)
|
|
|
|
func TestCreateGroup(t *testing.T) {
|
|
s := fixtures.Login(t, "thomas", "123")
|
|
|
|
group, err := s.Admin().CreateGroup(" My Friends ", " my-friends ")
|
|
fixtures.FailIfErr(t, err, "Failed to create group")
|
|
|
|
fixtures.AssertEq(t, "Number of users", "My Friends", group.Name)
|
|
fixtures.AssertEq(t, "Number of users", "my-friends", group.Reference)
|
|
}
|
|
|
|
func TestCantSeeSelfInGroup(t *testing.T) {
|
|
s := fixtures.Login(t, "thomas", "123")
|
|
|
|
caleb, err := lishwist.Register("caleb", "123")
|
|
fixtures.FailIfErr(t, err, "Failed to register caleb")
|
|
|
|
group, err := s.Admin().CreateGroup(" My Friends ", " my-friends ")
|
|
fixtures.FailIfErr(t, err, "Failed to create group")
|
|
|
|
err = s.Admin().AddUserToGroup(s.User().Id, group.Id)
|
|
fixtures.FailIfErr(t, err, "Failed to add self to group")
|
|
|
|
err = s.Admin().AddUserToGroup(caleb.Id, group.Id)
|
|
fixtures.FailIfErr(t, err, "Failed to add caleb to group")
|
|
|
|
group, err = s.GetGroupByReference("my-friends")
|
|
fixtures.FailIfErr(t, err, "Failed to get group")
|
|
fixtures.FatalAssert(t, "Group not nil", group != nil)
|
|
|
|
fixtures.AssertEq(t, "Group contains 2 users", 2, len(group.Members))
|
|
fixtures.AssertEq(t, "Group user 1 is thomas", "thomas", group.Members[0].Name)
|
|
fixtures.AssertEq(t, "Group user 2 is caleb", "caleb", group.Members[1].Name)
|
|
}
|