...
1
15
16 package proto
17
18 import "testing"
19
20 func TestCheckStripImportPrefix(t *testing.T) {
21 testCases := []struct {
22 name, prefix, rel, wantErr string
23 }{
24 {
25 name: "not in directory",
26 prefix: "/example.com/idl",
27 rel: "example.com",
28 wantErr: `proto_strip_import_prefix "/example.com/idl" not in directory example.com`,
29 },
30 {
31 name: "strip prefix at root",
32 prefix: "/include",
33 },
34 }
35 for _, tc := range testCases {
36 t.Run(tc.name, func(tt *testing.T) {
37 e := checkStripImportPrefix(tc.prefix, tc.rel)
38 if tc.wantErr == "" {
39 if e != nil {
40 t.Errorf("got:\n%v\n\nwant: nil\n", e)
41 }
42 } else {
43 if e == nil || e.Error() != tc.wantErr {
44 t.Errorf("got:\n%v\n\nwant:\n%s\n", e, tc.wantErr)
45 }
46 }
47 })
48 }
49 }
50
View as plain text