Mirror of github.com/gissleh/irc
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
652 B

  1. package irctest
  2. import (
  3. "errors"
  4. "strings"
  5. "testing"
  6. "git.aiterp.net/gisle/irc"
  7. )
  8. // AssertUserlist compares the userlist to a list of prefixed nicks
  9. func AssertUserlist(t *testing.T, channel *irc.Channel, assertedOrder ...string) error {
  10. users := channel.UserList().Users()
  11. order := make([]string, 0, len(users))
  12. for _, user := range users {
  13. order = append(order, user.PrefixedNick)
  14. }
  15. orderA := strings.Join(order, ", ")
  16. orderB := strings.Join(assertedOrder, ", ")
  17. if orderA != orderB {
  18. t.Logf("Userlist: %s", orderA)
  19. t.Logf("Asserted: %s", orderB)
  20. t.Fail()
  21. return errors.New("Userlists does not match")
  22. }
  23. return nil
  24. }