Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8cc7127

Browse files
Change lib list --updatable output to be clearer if no lib is updatable (#1053)
1 parent b615df5 commit 8cc7127

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

‎cli/lib/list.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ func (ir installedResult) Data() interface{} {
109109

110110
func (ir installedResult) String() string {
111111
if ir.installedLibs == nil || len(ir.installedLibs) == 0 {
112+
if listFlags.updatable {
113+
return "No updates available."
114+
}
112115
return "No libraries installed."
113116
}
114117
sort.Slice(ir.installedLibs, func(i, j int) bool {

‎test/test_lib.py‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,50 @@ def test_search_paragraph(run_command):
236236
assert result.ok
237237
libs_json = json.loads(result.stdout)
238238
assert 1 == len(libs_json.get("libraries"))
239+
240+
241+
def test_lib_list_with_updatable_flag(run_command):
242+
# Init the environment explicitly
243+
run_command("lib update-index")
244+
245+
# No libraries to update
246+
result = run_command("lib list --updatable")
247+
assert result.ok
248+
assert "" == result.stderr
249+
assert "No updates available." == result.stdout.strip()
250+
# No library to update in json
251+
result = run_command("lib list --updatable --format json")
252+
assert result.ok
253+
assert "" == result.stderr
254+
assert 0 == len(json.loads(result.stdout))
255+
256+
# Install outdated library
257+
assert run_command("lib install ArduinoJson@6.11.0")
258+
# Install latest version of library
259+
assert run_command("lib install WiFi101")
260+
261+
res = run_command("lib list --updatable")
262+
assert res.ok
263+
assert "" == res.stderr
264+
# lines = res.stdout.strip().splitlines()
265+
lines = [l.strip().split(maxsplit=4) for l in res.stdout.strip().splitlines()]
266+
assert 2 == len(lines)
267+
assert ["Name", "Installed", "Available", "Location", "Description"] in lines
268+
line = lines[1]
269+
assert "ArduinoJson" == line[0]
270+
assert "6.11.0" == line[1]
271+
# Verifies available version is not equal to installed one and not empty
272+
assert "6.11.0" != line[2]
273+
assert "" != line[2]
274+
assert "An efficient and elegant JSON library..." == line[4]
275+
276+
# Look at the JSON output
277+
res = run_command("lib list --updatable --format json")
278+
assert res.ok
279+
assert "" == res.stderr
280+
data = json.loads(res.stdout)
281+
assert 1 == len(data)
282+
# be sure data contains the available version
283+
assert "6.11.0" == data[0]["library"]["version"]
284+
assert "6.11.0" != data[0]["release"]["version"]
285+
assert "" != data[0]["release"]["version"]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /