MCPcopy Index your code
hub / github.com/coder/coder / agentClientCommand

Function agentClientCommand

cli/root_test.go:429–445  ·  view source on GitHub ↗

agentClientCommand creates a subcommand that creates an agent client and stores it in the provided clientRef. Used to test the properties of the client with various root command flags.

(clientRef **agentsdk.Client)

Source from the content-addressed store, hash-verified

427// agentClientCommand creates a subcommand that creates an agent client and stores it in the provided clientRef. Used to
428// test the properties of the client with various root command flags.
429func agentClientCommand(clientRef **agentsdk.Client) *serpent.Command {
430 agentAuth := &cli.AgentAuth{}
431 cmd := &serpent.Command{
432 Use: "agent-client",
433 Short: `Creates and agent client for testing.`,
434 Handler: func(inv *serpent.Invocation) error {
435 client, err := agentAuth.CreateClient()
436 if err != nil {
437 return xerrors.Errorf("create agent client: %w", err)
438 }
439 *clientRef = client
440 return nil
441 },
442 }
443 agentAuth.AttachOptions(cmd, false)
444 return cmd
445}
446
447func TestWrapTransportWithUserAgentHeader(t *testing.T) {
448 t.Parallel()

Callers 2

createAgentWithFlagsFunction · 0.85

Calls 3

CreateClientMethod · 0.95
AttachOptionsMethod · 0.95
ErrorfMethod · 0.45

Tested by

no test coverage detected