search_test.go 719 B

12345678910111213141516171819202122232425262728293031
  1. package ldap
  2. import (
  3. "reflect"
  4. "testing"
  5. )
  6. // TestNewEntry tests that repeated calls to NewEntry return the same value with the same input
  7. func TestNewEntry(t *testing.T) {
  8. dn := "testDN"
  9. attributes := map[string][]string{
  10. "alpha": {"value"},
  11. "beta": {"value"},
  12. "gamma": {"value"},
  13. "delta": {"value"},
  14. "epsilon": {"value"},
  15. }
  16. exectedEntry := NewEntry(dn, attributes)
  17. iteration := 0
  18. for {
  19. if iteration == 100 {
  20. break
  21. }
  22. testEntry := NewEntry(dn, attributes)
  23. if !reflect.DeepEqual(exectedEntry, testEntry) {
  24. t.Fatalf("consequent calls to NewEntry did not yield the same result:\n\texpected:\n\t%s\n\tgot:\n\t%s\n", exectedEntry, testEntry)
  25. }
  26. iteration = iteration + 1
  27. }
  28. }