Skip to content

Commit dbf8a33

Browse files
Migrate TestListWithFqbn from test_lib.py to lib_test.go
1 parent 54d6258 commit dbf8a33

File tree

2 files changed

+42
-35
lines changed

2 files changed

+42
-35
lines changed

internal/integrationtest/lib/lib_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,3 +406,45 @@ func TestListExitCode(t *testing.T) {
406406
require.NoError(t, err)
407407
require.Empty(t, stderr)
408408
}
409+
410+
func TestListWithFqbn(t *testing.T) {
411+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
412+
defer env.CleanUp()
413+
414+
// Init the environment explicitly
415+
_, _, err := cli.Run("core", "update-index")
416+
require.NoError(t, err)
417+
418+
// Install core
419+
_, _, err = cli.Run("core", "install", "arduino:avr")
420+
require.NoError(t, err)
421+
422+
// Look at the plain text output
423+
_, _, err = cli.Run("lib", "install", "ArduinoJson")
424+
require.NoError(t, err)
425+
_, _, err = cli.Run("lib", "install", "wm8978-esp32")
426+
require.NoError(t, err)
427+
428+
// Look at the plain text output
429+
stdout, stderr, err := cli.Run("lib", "list", "-b", "arduino:avr:uno")
430+
require.NoError(t, err)
431+
require.Empty(t, stderr)
432+
lines := strings.Split(strings.TrimSpace(string(stdout)), "\n")
433+
require.Len(t, lines, 2)
434+
435+
// Verifies library is compatible
436+
lines[1] = strings.Join(strings.Fields(lines[1]), " ")
437+
toks := strings.SplitN(lines[1], " ", 5)
438+
require.Len(t, toks, 5)
439+
require.Equal(t, "ArduinoJson", toks[0])
440+
441+
// Look at the JSON output
442+
stdout, stderr, err = cli.Run("lib", "list", "-b", "arduino:avr:uno", "--format", "json")
443+
require.NoError(t, err)
444+
require.Empty(t, stderr)
445+
requirejson.Len(t, stdout, 1)
446+
447+
// Verifies library is compatible
448+
requirejson.Query(t, stdout, ".[0] | .library | .name", "\"ArduinoJson\"")
449+
requirejson.Query(t, stdout, ".[0] | .library | .compatible_with | .\"arduino:avr:uno\"", "true")
450+
}

test/test_lib.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,41 +49,6 @@ def download_lib(url, download_dir):
4949
z.close()
5050

5151

52-
def test_list_with_fqbn(run_command):
53-
# Init the environment explicitly
54-
assert run_command(["core", "update-index"])
55-
56-
# Install core
57-
assert run_command(["core", "install", "arduino:avr"])
58-
59-
# Install some library
60-
assert run_command(["lib", "install", "ArduinoJson"])
61-
assert run_command(["lib", "install", "wm8978-esp32"])
62-
63-
# Look at the plain text output
64-
result = run_command(["lib", "list", "-b", "arduino:avr:uno"])
65-
assert result.ok
66-
assert "" == result.stderr
67-
lines = result.stdout.strip().splitlines()
68-
assert 2 == len(lines)
69-
70-
# Verifies library is compatible
71-
toks = [t.strip() for t in lines[1].split(maxsplit=4)]
72-
assert 5 == len(toks)
73-
assert "ArduinoJson" == toks[0]
74-
75-
# Look at the JSON output
76-
result = run_command(["lib", "list", "-b", "arduino:avr:uno", "--format", "json"], hide=True)
77-
assert result.ok
78-
assert "" == result.stderr
79-
data = json.loads(result.stdout)
80-
assert 1 == len(data)
81-
82-
# Verifies library is compatible
83-
assert data[0]["library"]["name"] == "ArduinoJson"
84-
assert data[0]["library"]["compatible_with"]["arduino:avr:uno"]
85-
86-
8752
def test_list_provides_includes_fallback(run_command):
8853
# Verifies "provides_includes" field is returned even if libraries don't declare
8954
# the "includes" property in their "library.properties" file

0 commit comments

Comments
 (0)