MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestHasPrefixes

Function TestHasPrefixes

backend/common/util_test.go:11–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestHasPrefixes(t *testing.T) {
12 type args struct {
13 src string
14 prefixes []string
15 }
16 tests := []struct {
17 name string
18 args args
19 want bool
20 }{
21 {
22 name: "has prefixes",
23 args: args{
24 src: "abc",
25 prefixes: []string{"a", "b", "c"},
26 },
27 want: true,
28 },
29 {
30 name: "has no matching prefix",
31 args: args{
32 src: "this is a sentence",
33 prefixes: []string{"that", "x", "y"},
34 },
35 want: false,
36 },
37 }
38 for i := range tests {
39 tt := tests[i]
40 t.Run(tt.name, func(t *testing.T) {
41 got := HasPrefixes(tt.args.src, tt.args.prefixes...)
42 assert.Equal(t, got, tt.want)
43 })
44 }
45}
46
47func TestTruncateString(t *testing.T) {
48 tests := []struct {

Callers

nothing calls this directly

Calls 3

HasPrefixesFunction · 0.85
EqualMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected