inlet/geoip: rename country-database to geo-database

This is a first step to accept another kind of GeoIP database (like
City). This also introduces the way we want to deprecate stuff:
transform the map structure.
This commit is contained in:
Vincent Bernat
2022-07-29 15:54:31 +02:00
parent 6c2169e5f3
commit 8ee2750012
14 changed files with 226 additions and 52 deletions

View File

@@ -0,0 +1,29 @@
// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
package helpers
import "testing"
func TestMapStructureMatchName(t *testing.T) {
cases := []struct {
mapKey string
fieldName string
expected bool
}{
{"one", "one", true},
{"one", "One", true},
{"one-two", "OneTwo", true},
{"onetwo", "OneTwo", true},
{"One-Two", "OneTwo", true},
{"two", "one", false},
}
for _, tc := range cases {
got := MapStructureMatchName(tc.mapKey, tc.fieldName)
if got && !tc.expected {
t.Errorf("%q == %q but expected !=", tc.mapKey, tc.fieldName)
} else if !got && tc.expected {
t.Errorf("%q != %q but expected ==", tc.mapKey, tc.fieldName)
}
}
}