-
Notifications
You must be signed in to change notification settings - Fork 101
/
verifier_test.go
64 lines (57 loc) · 1.56 KB
/
verifier_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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package maxminddb
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestVerifyOnGoodDatabases(t *testing.T) {
databases := []string{
"GeoIP2-Anonymous-IP-Test.mmdb",
"GeoIP2-City-Test.mmdb",
"GeoIP2-Connection-Type-Test.mmdb",
"GeoIP2-Country-Test.mmdb",
"GeoIP2-Domain-Test.mmdb",
"GeoIP2-ISP-Test.mmdb",
"GeoIP2-Precision-Enterprise-Test.mmdb",
"MaxMind-DB-no-ipv4-search-tree.mmdb",
"MaxMind-DB-string-value-entries.mmdb",
"MaxMind-DB-test-decoder.mmdb",
"MaxMind-DB-test-ipv4-24.mmdb",
"MaxMind-DB-test-ipv4-28.mmdb",
"MaxMind-DB-test-ipv4-32.mmdb",
"MaxMind-DB-test-ipv6-24.mmdb",
"MaxMind-DB-test-ipv6-28.mmdb",
"MaxMind-DB-test-ipv6-32.mmdb",
"MaxMind-DB-test-mixed-24.mmdb",
"MaxMind-DB-test-mixed-28.mmdb",
"MaxMind-DB-test-mixed-32.mmdb",
"MaxMind-DB-test-nested.mmdb",
}
for _, database := range databases {
t.Run(database, func(t *testing.T) {
reader, err := Open(testFile(database))
require.NoError(t, err)
require.NoError(
t,
reader.Verify(),
"Received error (%v) when verifying %v",
err,
database,
)
})
}
}
func TestVerifyOnBrokenDatabases(t *testing.T) {
databases := []string{
"GeoIP2-City-Test-Broken-Double-Format.mmdb",
"MaxMind-DB-test-broken-pointers-24.mmdb",
"MaxMind-DB-test-broken-search-tree-24.mmdb",
}
for _, database := range databases {
reader, err := Open(testFile(database))
require.NoError(t, err)
assert.Error(t, reader.Verify(),
"Did not receive expected error when verifying %v", database,
)
}
}