Skip to content

"lib list" now returns an empty json array when there are no libraries installed #511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cli/lib/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ func runListCommand(cmd *cobra.Command, args []string) {
}

libs := res.GetInstalledLibrary()
feedback.PrintResult(installedResult{libs})

// To uniform the output to other commands, when there are no result
// print out an empty slice.
if libs == nil {
libs = []*rpc.InstalledLibrary{}
}

feedback.PrintResult(installedResult{libs})
logrus.Info("Done")
}

Expand Down
14 changes: 11 additions & 3 deletions test/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_list(run_command):
result = run_command("lib list --format json")
assert result.ok
assert "" == result.stderr
assert "null" == result.stdout
assert 0 == len(json.loads(result.stdout))

# Install something we can list at a version older than latest
result = run_command("lib install [email protected]")
Expand Down Expand Up @@ -70,13 +70,21 @@ def test_update_index(run_command):
)


def test_remove(run_command):
libs = ['"AzureIoTProtocol_MQTT"', '"CMMC MQTT Connector"', '"WiFiNINA"']
def test_uninstall(run_command):
libs = ['"AzureIoTProtocol_MQTT"', '"WiFiNINA"']
assert run_command("lib install {}".format(" ".join(libs)))

result = run_command("lib uninstall {}".format(" ".join(libs)))
assert result.ok

def test_uninstall_spaces(run_command):
key = '"LiquidCrystal I2C"'
assert run_command("lib install {}".format(key))
assert run_command("lib uninstall {}".format(key))
result = run_command("lib list --format json")
assert result.ok
assert len(json.loads(result.stdout)) == 0


def test_search(run_command):
assert run_command("lib update-index")
Expand Down