Files
akvorado/common/helpers/mapstructure_test.go
Vincent Bernat 8ee2750012 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.
2022-07-29 15:55:39 +02:00

30 lines
701 B
Go

// 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)
}
}
}