search_test.go 722 B

1234567891011121314151617181920212223242526272829303132
  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. executedEntry := NewEntry(dn, attributes)
  17. iteration := 0
  18. for {
  19. if iteration == 100 {
  20. break
  21. }
  22. testEntry := NewEntry(dn, attributes)
  23. if !reflect.DeepEqual(executedEntry, testEntry) {
  24. t.Fatalf("subsequent calls to NewEntry did not yield the same result:\n\texpected:\n\t%s\n\tgot:\n\t%s\n", executedEntry, testEntry)
  25. }
  26. iteration = iteration + 1
  27. }
  28. }