Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions internal/templates/cli_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,42 @@ func TestGoMainTemplate_AdvertisesRuntimeAuthScheme(t *testing.T) {
})
}
}

// TestGoMainTemplate_DocCommentsStartOnTheirOwnLine verifies the optional
// loadAgentCard block leaves a blank line before the next doc comment, so gofmt
// never glues it onto the closing brace of the function above.
func TestGoMainTemplate_DocCommentsStartOnTheirOwnLine(t *testing.T) {
tests := []struct {
name string
extendedAgentCard bool
}{
{"without the extended agent card", false},
{"with the extended agent card", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r, err := NewRegistry("go")
if err != nil {
t.Fatalf("NewRegistry: %v", err)
}
tmpl, err := r.GetTemplate("main.go")
if err != nil {
t.Fatalf("GetTemplate(main.go): %v", err)
}
adl := minimalGoADL()
adl.Spec.Capabilities.ExtendedAgentCard = tt.extendedAgentCard

rendered, err := NewWithRegistry("main.go", r).Execute(tmpl, Context{ADL: adl, Language: "go"})
if err != nil {
t.Fatalf("Execute: %v", err)
}

if !strings.Contains(rendered, "}\n\n// newRootCmd builds") {
t.Error("newRootCmd doc comment does not start on its own line after a blank line")
}
if tt.extendedAgentCard && !strings.Contains(rendered, "}\n\n// loadAgentCard reads") {
t.Error("loadAgentCard doc comment does not start on its own line after a blank line")
}
})
}
}
2 changes: 1 addition & 1 deletion internal/templates/languages/go/main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func advertiseAuthScheme(a2aServer server.A2AServer, auth serverConfig.AuthConfi
return true
}

{{- if .ADL.Spec.Capabilities.ExtendedAgentCard }}
{{ if .ADL.Spec.Capabilities.ExtendedAgentCard -}}
// loadAgentCard reads a .well-known agent-card JSON file into a typed AgentCard.
// It is used to seed the authenticated extended card (A2A spec section 7) from
// the same static card the public endpoint serves; enrich the returned card with
Expand Down
Loading