Skip to content

Commit

Permalink
Add MaxMind GeoIP test DB to use in the tests
Browse files Browse the repository at this point in the history
Obtained from: https://github.com/maxmind/MaxMind-DB/blob/689bbf927360cee2285fd472fc1eb6671f335979/test-data/MaxMind-DB-test-ipv4-24.mmdb

The database is tiny and contains just a few records. That doesn't
matter too much, as we simply want to be able to initialise and use
analytics.GeoIPDB in the tests.

initialiseSystem doesn't return any error, so we have to check for nil
ourselves to be sure that the database was loaded correctly.

In preparation to fix TykTechnologies#352 with a test.

Updates TykTechnologies#352.
  • Loading branch information
mvdan authored and buger committed Feb 3, 2017
1 parent 3291045 commit ac220ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ petstore.json
*.prof
*.pdf
*.mmdb
!testdata/*.mmdb
*.pid
coprocess_gen_test.go
session_state_gen_test.go
Expand Down
8 changes: 7 additions & 1 deletion gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http/httptest"
"net/url"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
Expand All @@ -28,7 +29,12 @@ func TestMain(m *testing.M) {
panic(err)
}
config.EnableAnalytics = true
initialiseSystem(map[string]interface{}{})
config.AnalyticsConfig.EnableGeoIP = true
config.AnalyticsConfig.GeoIPDBLocation = filepath.Join("testdata", "MaxMind-DB-test-ipv4-24.mmdb")
initialiseSystem(nil)
if analytics.GeoIPDB == nil {
panic("GeoIPDB was not initialized")
}
exitCode := m.Run()

os.RemoveAll(config.AppPath)
Expand Down
Binary file added testdata/MaxMind-DB-test-ipv4-24.mmdb
Binary file not shown.

0 comments on commit ac220ff

Please sign in to comment.