config_test.go 480 B

12345678910111213141516171819202122232425
  1. package geoip
  2. import (
  3. "reflect"
  4. "testing"
  5. "github.com/mholt/caddy"
  6. )
  7. func TestParseConfig(t *testing.T) {
  8. controller := caddy.NewTestController("http", `
  9. localhost:8080
  10. geoip path/to/maxmind/db
  11. `)
  12. actual, err := parseConfig(controller)
  13. if err != nil {
  14. t.Errorf("parseConfig return err: %v", err)
  15. }
  16. expected := Config{
  17. DatabasePath: "path/to/maxmind/db",
  18. }
  19. if !reflect.DeepEqual(expected, actual) {
  20. t.Errorf("Expected %v actual %v", expected, actual)
  21. }
  22. }