mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
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:
29
common/helpers/mapstructure_test.go
Normal file
29
common/helpers/mapstructure_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user