-
Notifications
You must be signed in to change notification settings - Fork 187
Expand file tree
/
Copy pathgitconfig_test.go
More file actions
36 lines (33 loc) · 870 Bytes
/
gitconfig_test.go
File metadata and controls
36 lines (33 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package git
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfigKeyMatchesPrefix(t *testing.T) {
for _, p := range []struct {
key, prefix string
expectedBool bool
expectedString string
}{
{"foo.bar", "", true, "foo.bar"},
{"foo.bar", "foo", true, "bar"},
{"foo.bar", "foo.", true, "bar"},
{"foo.bar", "foo.bar", true, ""},
{"foo.bar", "foo.bar.", false, ""},
{"foo.bar", "foo.bar.baz", false, ""},
{"foo.bar", "foo.barbaz", false, ""},
{"foo.bar.baz", "foo.bar", true, "baz"},
{"foo.barbaz", "foo.bar", false, ""},
{"foo.bar", "bar", false, ""},
} {
t.Run(
fmt.Sprintf("TestConfigKeyMatchesPrefix(%q, %q)", p.key, p.prefix),
func(t *testing.T) {
ok, s := configKeyMatchesPrefix(p.key, p.prefix)
assert.Equal(t, p.expectedBool, ok)
assert.Equal(t, p.expectedString, s)
},
)
}
}