Skip to content

Commit e7e4394

Browse files
committed
auto-complete tests
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
1 parent 1f2980b commit e7e4394

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

e2e/binary/binary_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package binary
55

66
import (
7+
"strings"
78
"testing"
89

910
"github.com/stretchr/testify/require"
@@ -40,3 +41,48 @@ func TestExecMissingKeys(t *testing.T) {
4041
require.Contains(t, res.Stderr, "OPENAI_API_KEY")
4142
})
4243
}
44+
func TestAutoComplete(t *testing.T) {
45+
t.Run("cli plugin auto-complete cagent", func(t *testing.T) {
46+
res, err := Exec(binDir+"/cagent", "__complete", "ser")
47+
require.NoError(t, err)
48+
props := lines(res.Stdout)
49+
require.Contains(t, props[0], "serve")
50+
})
51+
52+
t.Run("cli plugin auto-complete docker-agent", func(t *testing.T) {
53+
res, err := Exec(binDir+"/docker-agent", "__complete", "ser")
54+
require.NoError(t, err)
55+
props := lines(res.Stdout)
56+
require.Contains(t, props[0], "serve")
57+
})
58+
59+
t.Run("cli plugin auto-complete docker-agent sub commands", func(t *testing.T) {
60+
res, err := Exec(binDir+"/docker-agent", "__complete", "serve", "")
61+
require.NoError(t, err)
62+
props := lines(res.Stdout)
63+
require.Contains(t, props[0], "a2a")
64+
require.Contains(t, props[0], "Start an agent as an A2A")
65+
require.Contains(t, props[1], "acp")
66+
require.Contains(t, props[2], "api")
67+
require.Contains(t, props[3], "mcp")
68+
})
69+
70+
t.Run("cli plugin auto-complete docker agent", func(t *testing.T) {
71+
res, err := ExecWithEnv([]string{"DOCKER_CLI_PLUGIN_ORIGINAL_CLI_COMMAND=/docker-agent"}, binDir+"/docker-agent", "__complete", "agent", "ser")
72+
require.NoError(t, err)
73+
props := lines(res.Stdout)
74+
require.Contains(t, props[0], "serve")
75+
})
76+
77+
t.Run("cli plugin auto-complete docker agent sub commands", func(t *testing.T) {
78+
res, err := ExecWithEnv([]string{"DOCKER_CLI_PLUGIN_ORIGINAL_CLI_COMMAND=/docker-agent"}, binDir+"/docker-agent", "__complete", "agent", "serve", "")
79+
require.NoError(t, err)
80+
props := lines(res.Stdout)
81+
require.Contains(t, props[0], "a2a")
82+
require.Contains(t, props[1], "acp")
83+
})
84+
}
85+
86+
func lines(s string) []string {
87+
return strings.Split(s, "\n")
88+
}

e2e/binary/shellout.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ func Exec(cmd string, args ...string) (CmdResult, error) {
2424
return ExecWithContextInDir(context.Background(), "", cmd, args, nil)
2525
}
2626

27+
func ExecWithEnv(env []string, cmd string, args ...string) (CmdResult, error) {
28+
return ExecWithContextInDir(context.Background(), "", cmd, args, env)
29+
}
30+
2731
func ExecWithContextAndEnv(ctx context.Context, env []string, cmd string, args ...string) (CmdResult, error) {
2832
return ExecWithContextInDir(ctx, "", cmd, args, env)
2933
}

0 commit comments

Comments
 (0)