|
| 1 | +# This file is part of arduino-cli. |
| 2 | +# |
| 3 | +# Copyright 2019 ARDUINO SA (http://www.arduino.cc/) |
| 4 | +# |
| 5 | +# This software is released under the GNU General Public License version 3, |
| 6 | +# which covers the main part of arduino-cli. |
| 7 | +# The terms of this license can be found at: |
| 8 | +# https://www.gnu.org/licenses/gpl-3.0.en.html |
| 9 | +# |
| 10 | +# You can be released from the requirements of the above licenses by purchasing |
| 11 | +# a commercial license. Buying such a license is mandatory if you want to modify or |
| 12 | +# otherwise use the software for commercial activities involving the Arduino |
| 13 | +# software without disclosing the source code of your own applications. To purchase |
| 14 | +# a commercial license, send an email to [email protected]. |
| 15 | +import pytest |
| 16 | +import simplejson as json |
| 17 | + |
| 18 | +from .common import running_on_ci |
| 19 | + |
| 20 | + |
| 21 | +def test_core_search(run_command): |
| 22 | + url = "https://github.com/raw/arduino/arduino-cli/master/test/testdata/test_index.json" |
| 23 | + assert run_command("core update-index --additional-urls={}".format(url)) |
| 24 | + # list all |
| 25 | + result = run_command("core search") |
| 26 | + assert result.ok |
| 27 | + assert 3 < len(result.stdout.splitlines()) |
| 28 | + result = run_command("core search --format json") |
| 29 | + assert result.ok |
| 30 | + data = json.loads(result.stdout) |
| 31 | + assert 1 < len(data) |
| 32 | + # search a specific core |
| 33 | + result = run_command("core search avr") |
| 34 | + assert result.ok |
| 35 | + assert 2 < len(result.stdout.splitlines()) |
| 36 | + result = run_command("core search avr --format json") |
| 37 | + assert result.ok |
| 38 | + data = json.loads(result.stdout) |
| 39 | + assert 0 < len(data) |
| 40 | + # additional URL |
| 41 | + result = run_command( |
| 42 | + "core search test_core --format json --additional-urls={}".format(url) |
| 43 | + ) |
| 44 | + assert result.ok |
| 45 | + data = json.loads(result.stdout) |
| 46 | + assert 1 == len(data) |
| 47 | + # show all versions |
| 48 | + result = run_command( |
| 49 | + "core search test_core --all --format json --additional-urls={}".format(url) |
| 50 | + ) |
| 51 | + assert result.ok |
| 52 | + data = json.loads(result.stdout) |
| 53 | + assert 2 == len(data) |
0 commit comments