Debian Codegraph @

protoc_test.go

raw symbols SCIP
1 /*
2 Copyright The containerd Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package mainscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/
18
19 import "testingscip-go gomod github.com/golang/go/src go1.13 testing/"
20
21 func TestMkcmdscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/TestMkcmd().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
22 testcases := []struct {
23 name string
24 cmd protocCmdscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#
25 expectedV1 string
26 expectedV2 string
27 }{
28 {
29 name: "basic",
30 cmd: protocCmdscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#{Namesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Names.: []string{"go"}, Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Generators.: []generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#{{Namescip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#Name.: "go"}}},
31 expectedV1: "protoc -I --go_out=import_path=:",
32 expectedV2: "protoc -I --go_out=",
33 },
34 {
35 name: "plugin",
36 cmd: protocCmdscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#{Namesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Names.: []string{"go"}, Pluginsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Plugins.: []string{"grpc"}, Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Generators.: []generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#{{Namescip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#Name.: "go"}}},
37 expectedV1: "protoc -I --go_out=plugins=grpc,import_path=:",
38 expectedV2: "protoc -I --go_out=",
39 },
40 {
41 name: "use protoc-gen-go-grpc instead of plugins",
42 cmd: protocCmdscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#{Namesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Names.: []string{"go", "go-grpc"}, Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Generators.: []generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#{{Namescip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#Name.: "go"}, {Namescip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#Name.: "go-grpc"}}},
43 expectedV1: "protoc -I --go_out=import_path=: --go-grpc_out=import_path=:",
44 expectedV2: "protoc -I --go_out= --go-grpc_out=",
45 },
46 {
47 name: "use custom parameters",
48 cmd: protocCmdscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#{
49 Namesscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Names.: []string{"go", "go-ttrpc"},
50 Generatorsscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Generators.: []generatorscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#{
51 {
52 Namescip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#Name.: "go",
53 Parametersscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#Parameters.: map[string]string{
54 "Mpath": "newpath",
55 },
56 },
57 {
58 Namescip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#Name.: "go-ttrpc",
59 Parametersscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/generator#Parameters.: map[string]string{
60 "prefix": "TTRPC",
61 },
62 },
63 },
64 },
65 expectedV1: "protoc -I --go_out=import_path=: --go-ttrpc_out=import_path=:",
66 expectedV2: "protoc -I --go_out= --go_opt=Mpath=newpath --go-ttrpc_out= --go-ttrpc_opt=prefix=TTRPC",
67 },
68 }
69 for _, tc := range testcases {
70 t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().(tc.name+"V1", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
71 cmd := &tc.cmd
72 cmd.Versionscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Version. = 1
73
74 s, err := cmd.mkcmdscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#mkcmd().()
75 if err != nil {
76 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("err must be nil but %+v", err)
77 }
78
79 if s != tc.expectedV1 {
80 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().(`s must be %q, but %q`, tc.expectedV1, s)
81 }
82 })
83 t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().(tc.name+"V2", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
84 cmd := &tc.cmd
85 cmd.Versionscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#Version. = 2
86
87 s, err := cmd.mkcmdscip-go gomod github.com/containerd/protobuild . `github.com/containerd/protobuild`/protocCmd#mkcmd().()
88 if err != nil {
89 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("err must be nil but %+v", err)
90 }
91
92 if s != tc.expectedV2 {
93 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().(`s must be %q, but %q`, tc.expectedV2, s)
94 }
95 })
96 }
97 }