mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
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.
30 lines
701 B
Go
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)
|
|
}
|
|
}
|
|
}
|