Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b56f331

Browse files
committedAug 18, 2022
Migrated TestStaticCompletions from test_completion.py to completion_test.go
1 parent 203b4c1 commit b56f331

File tree

2 files changed

+24
-32
lines changed

2 files changed

+24
-32
lines changed
 

‎internal/integrationtest/completion/completion_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,27 @@ func TestCompletionPowershellNoDesc(t *testing.T) {
169169
require.Empty(t, stdout)
170170
require.Contains(t, string(stderr), "Error: command description is not supported by powershell")
171171
}
172+
173+
// test if the completion suggestions returned are meaningful
174+
// we use the __complete hidden command
175+
// https://github.com/spf13/cobra/blob/master/shell_completions.md#debugging
176+
177+
// test static completions
178+
func TestStaticCompletions(t *testing.T) {
179+
env := testsuite.NewEnvironment(t)
180+
defer env.CleanUp()
181+
182+
cli := integrationtest.NewArduinoCliWithinEnvironment(env, &integrationtest.ArduinoCLIConfig{
183+
ArduinoCLIPath: paths.New("..", "..", "..", "arduino-cli"),
184+
UseSharedStagingFolder: true,
185+
})
186+
187+
stdout, _, _ := cli.Run("__complete", "--format", "")
188+
require.Contains(t, string(stdout), "json")
189+
190+
stdout, _, _ = cli.Run("__complete", "--log-format", "")
191+
require.Contains(t, string(stdout), "json")
192+
193+
stdout, _, _ = cli.Run("__complete", "--log-level", "")
194+
require.Contains(t, string(stdout), "trace")
195+
}

‎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)
Please sign in to comment.