forked from aablinov/caddy-geoip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
39 lines (36 loc) · 937 Bytes
/
config_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package geoip
import (
"reflect"
"testing"
"github.com/mholt/caddy"
)
func TestParseConfig(t *testing.T) {
controller := caddy.NewTestController("http", `
localhost:8080
geoip {
set_header_country_code "Code"
set_header_country_name "CountryName"
set_header_country_eu "Eu"
set_header_city_name "CityName"
set_header_location_lat "Lat"
set_header_location_lon "Lon"
set_header_location_tz "TZ"
}
`)
actual, err := parseConfig(controller)
if err != nil {
t.Errorf("parseConfig return err: %v", err)
}
expected := Config{
HeaderNameCountryCode: "Code",
HeaderNameCountryName: "CountryName",
HeaderNameCountryIsEU: "Eu",
HeaderNameCityName: "CityName",
HeaderNameLocationLat: "Lat",
HeaderNameLocationLon: "Lon",
HeaderNameLocationTimeZone: "TZ",
}
if !reflect.DeepEqual(expected, actual) {
t.Errorf("Expected %v actual %v", expected, actual)
}
}