MCPcopy Create free account
hub / github.com/goadesign/goa / TestProtoBufMessageDefJSONNameOptionOneOf

Function TestProtoBufMessageDefJSONNameOptionOneOf

grpc/codegen/protobuf_test.go:206–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

204}
205
206func TestProtoBufMessageDefJSONNameOptionOneOf(t *testing.T) {
207 attr := &expr.AttributeExpr{
208 Type: &expr.Union{
209 TypeName: "Animal",
210 Values: []*expr.NamedAttributeExpr{
211 {
212 Name: "Cat",
213 Attribute: &expr.AttributeExpr{
214 Type: expr.String,
215 Meta: expr.MetaExpr{
216 "rpc:tag": []string{"1"},
217 "proto:tag:json": []string{"cat"},
218 },
219 },
220 },
221 },
222 },
223 }
224 sd := &ServiceData{Scope: codegen.NewNameScope()}
225 def := protoBufMessageDef(attr, sd)
226 if !strings.Contains(def, `json_name = "cat"`) {
227 t.Fatalf("expected json_name option in oneof, got %q", def)
228 }
229}

Callers

nothing calls this directly

Calls 2

NewNameScopeFunction · 0.92
protoBufMessageDefFunction · 0.85

Tested by

no test coverage detected