Skip to content

Commit b16fd2f

Browse files
Migrated TestStaticCompletions from test_completion.py to completion_test.go
1 parent 1c00b0e commit b16fd2f

File tree

2 files changed

+19
-32
lines changed

2 files changed

+19
-32
lines changed

internal/integrationtest/completion/completion_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,22 @@ func TestCompletionPowershellNoDesc(t *testing.T) {
122122
require.Empty(t, stdout)
123123
require.Contains(t, string(stderr), "Error: command description is not supported by powershell")
124124
}
125+
126+
// test if the completion suggestions returned are meaningful
127+
// we use the __complete hidden command
128+
// https://github.com/spf13/cobra/blob/master/shell_completions.md#debugging
129+
130+
// test static completions
131+
func TestStaticCompletions(t *testing.T) {
132+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
133+
defer env.CleanUp()
134+
135+
stdout, _, _ := cli.Run("__complete", "--format", "")
136+
require.Contains(t, string(stdout), "json")
137+
138+
stdout, _, _ = cli.Run("__complete", "--log-format", "")
139+
require.Contains(t, string(stdout), "json")
140+
141+
stdout, _, _ = cli.Run("__complete", "--log-level", "")
142+
require.Contains(t, string(stdout), "trace")
143+
}

test/test_completion.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,6 @@
1414
# a commercial license, send an email to license@arduino.cc.
1515

1616

17-
# test if the completion suggestions returned are meaningful
18-
# we use the __complete hidden command
19-
# https://github.com/spf13/cobra/blob/master/shell_completions.md#debugging
20-
21-
# test static completions
22-
def test_static_completions(run_command):
23-
result = run_command(
24-
[
25-
"__complete",
26-
"--format",
27-
"",
28-
]
29-
)
30-
assert "json" in result.stdout
31-
result = run_command(
32-
[
33-
"__complete",
34-
"--log-format",
35-
"",
36-
]
37-
)
38-
assert "json" in result.stdout
39-
result = run_command(
40-
[
41-
"__complete",
42-
"--log-level",
43-
"",
44-
]
45-
)
46-
assert "trace" in result.stdout
47-
48-
4917
# here we test if the completions coming from the core are working
5018
def test_config_completion(run_command):
5119
result = run_command(["__complete", "config", "add", ""])

0 commit comments

Comments
 (0)