fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

1package zoekt 2 3import ( 4 "strings" 5 "testing" 6) 7 8func TestShardName(t *testing.T) { 9 tests := []struct { 10 name string 11 indexDir string 12 prefix string 13 version int 14 shardNum int 15 expected string 16 }{ 17 { 18 name: "short prefix", 19 indexDir: "index", 20 prefix: "short", 21 version: 1, 22 shardNum: 42, 23 expected: "index/short_v1.00042.zoekt", 24 }, 25 { 26 name: "long prefix truncated", 27 indexDir: "index", 28 prefix: strings.Repeat("a", 300), 29 version: 2, 30 shardNum: 1, 31 expected: "index/" + strings.Repeat("a", 200) + "003ef1ba" + "_v2.00001.zoekt", 32 }, 33 { 34 name: "empty indexDir", 35 prefix: "short", 36 version: 1, 37 expected: "short_v1.00000.zoekt", 38 }, 39 } 40 41 for _, test := range tests { 42 t.Run(test.name, func(t *testing.T) { 43 actual := ShardName(test.indexDir, test.prefix, test.version, test.shardNum) 44 if actual != test.expected { 45 t.Errorf("expected %q, got %q", test.expected, actual) 46 } 47 }) 48 } 49}