(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestConfigKeyMatchesPrefix(t *testing.T) { |
| 11 | for _, p := range []struct { |
| 12 | key, prefix string |
| 13 | expectedBool bool |
| 14 | expectedString string |
| 15 | }{ |
| 16 | {"foo.bar", "", true, "foo.bar"}, |
| 17 | {"foo.bar", "foo", true, "bar"}, |
| 18 | {"foo.bar", "foo.", true, "bar"}, |
| 19 | {"foo.bar", "foo.bar", true, ""}, |
| 20 | {"foo.bar", "foo.bar.", false, ""}, |
| 21 | {"foo.bar", "foo.bar.baz", false, ""}, |
| 22 | {"foo.bar", "foo.barbaz", false, ""}, |
| 23 | {"foo.bar.baz", "foo.bar", true, "baz"}, |
| 24 | {"foo.barbaz", "foo.bar", false, ""}, |
| 25 | {"foo.bar", "bar", false, ""}, |
| 26 | } { |
| 27 | t.Run( |
| 28 | fmt.Sprintf("TestConfigKeyMatchesPrefix(%q, %q)", p.key, p.prefix), |
| 29 | func(t *testing.T) { |
| 30 | ok, s := configKeyMatchesPrefix(p.key, p.prefix) |
| 31 | assert.Equal(t, p.expectedBool, ok) |
| 32 | assert.Equal(t, p.expectedString, s) |
| 33 | }, |
| 34 | ) |
| 35 | } |
| 36 | } |
nothing calls this directly
no test coverage detected