Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
47eebca
Migrate TestCoreSearchNoArgs from test_core.py to core_test.go
MatteoPologruto Oct 21, 2022
d7f0727
Migrate TestCoreUpdateIndexUrlNotFound from test_core.py to core_test.go
MatteoPologruto Oct 21, 2022
b2dc757
Migrate TestCoreUpdateIndexInternalServerError from test_core.py to c…
MatteoPologruto Oct 21, 2022
c1c4e96
Migrate TestCoreInstallWithoutUpdateIndex from test_core.py to core_t…
MatteoPologruto Oct 21, 2022
f0bc229
Migrate TestCoreDownload from test_core.py to core_test.go
MatteoPologruto Oct 21, 2022
c21c5f6
Migrate TestCoreInstall from test_core.py to core_test.go
MatteoPologruto Oct 21, 2022
5e0ea1e
Migrate TestCoreUninstall from test_core.py to core_test.go
MatteoPologruto Oct 21, 2022
11bb175
Migrate TestCoreUninstallToolDependencyRemoval from test_core.py to c…
MatteoPologruto Oct 21, 2022
f3f61e7
Migrate TestCoreZipslip from test_core.py to core_test.go
MatteoPologruto Oct 21, 2022
7cd3ee5
Migrate TestCoreBrokenInstall from test_core.py to core_test.go
MatteoPologruto Oct 21, 2022
e4cef88
Migrate TestCoreUpdateWithLocalUrl from test_core.py to core_test.go
MatteoPologruto Oct 24, 2022
7915701
Migrate TestCoreSearchManuallyInstalledCoresNotPrinted from test_core…
MatteoPologruto Oct 24, 2022
bb2ebd7
Migrate TestCoreListAllManuallyInstalledCore from test_core.py to cor…
MatteoPologruto Oct 24, 2022
8daa1fa
Migrate TestCoreListUpdatableAllFlags from test_core.py to core_test.go
MatteoPologruto Oct 24, 2022
2453d09
Migrate TestCoreUpgradeRemovesUnusedTools from test_core.py to core_t…
MatteoPologruto Oct 24, 2022
4d503be
Migrate TestCoreInstallRemovesUnusedTools from test_core.py to core_t…
MatteoPologruto Oct 24, 2022
f7618d6
Migrate TestCoreListWithInstalledJson from test_core.py to core_test.go
MatteoPologruto Oct 24, 2022
ab6c90d
Migrate TestCoreSearchSortedResults from test_core.py to core_test.go
MatteoPologruto Oct 25, 2022
49f010a
Migrate TestCoreListSortedResults from test_core.py to core_test.go
MatteoPologruto Oct 25, 2022
6afbd7f
Migrate TestCoreListDeprecatedPlatformWithInstalledJson from test_cor…
MatteoPologruto Oct 25, 2022
1c05d52
Migrate TestCoreListPlatformWithoutPlatformTxt from test_core.py to c…
MatteoPologruto Oct 25, 2022
98c576f
Migrate TestCoreWithMissingCustomBoardOptionsIsLoaded from test_core.…
MatteoPologruto Oct 25, 2022
7706e93
Migrate TestCoreListOutdatedCore from test_core.py to core_test.go
MatteoPologruto Oct 25, 2022
0fc96a1
Migrate TestCoreLoadingPackageManager from test_core.py to core_test.go
MatteoPologruto Oct 25, 2022
d7c54d0
Migrate TestCoreIndexWithoutChecksum from test_core.py to core_test.go
MatteoPologruto Oct 25, 2022
b65fa7c
Migrate TestCoreInstallEsp32 from test_core.py to core_test.go
MatteoPologruto Oct 25, 2022
85719ae
Migrate TestCoreSearchUpdateIndexDelay from test_core.py to core_test.go
MatteoPologruto Oct 26, 2022
0eb7441
Migrate TestCoreDownloadMultiplePlatforms from test_core.py to core_t…
MatteoPologruto Oct 26, 2022
0594c35
Migrate TestCoreInstallCreatesInstalledJson to core_test.go and delet…
MatteoPologruto Nov 10, 2022
20ea2a1
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 15, 2022
91f2c77
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 15, 2022
e352d4c
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 15, 2022
68dae7a
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 15, 2022
4240bfc
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 15, 2022
4321d1f
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 15, 2022
b066a1e
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 15, 2022
69c7ab4
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 15, 2022
f991379
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 15, 2022
ba9b5ae
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 16, 2022
cbd6da2
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 16, 2022
c84d65e
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 16, 2022
1010cc1
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 16, 2022
279733e
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 16, 2022
9547c91
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 16, 2022
d67c4d5
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 16, 2022
ba59e28
Update internal/integrationtest/core/core_test.go
MatteoPologruto Nov 16, 2022
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
Next Next commit
Migrate TestCoreSearchNoArgs from test_core.py to core_test.go
  • Loading branch information
MatteoPologruto committed Nov 9, 2022
commit 47eebcaf1f6e757fa28db52bff52189c5568cdab
62 changes: 62 additions & 0 deletions internal/integrationtest/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,65 @@ func TestCoreSearch(t *testing.T) {
runSearch("ble nano", "arduino:mbed_nano")
runSearch("nano", "arduino:avr", "arduino:megaavr", "arduino:samd", "arduino:mbed_nano")
}

func TestCoreSearchNoArgs(t *testing.T) {
// This tests `core search` with and without additional URLs in case no args
// are passed (i.e. all results are shown).

env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
defer env.CleanUp()

// Set up an http server to serve our custom index file
testIndex := paths.New("..", "testdata", "test_index.json")
url := env.HTTPServeFile(8000, testIndex)

// update custom index and install test core (installed cores affect `core search`)
_, _, err := cli.Run("core", "update-index", "--additional-urls="+url.String())
require.NoError(t, err)
_, _, err = cli.Run("core", "install", "test:x86", "--additional-urls="+url.String())
require.NoError(t, err)

// list all with no additional urls, ensure the test core won't show up
stdout, _, err := cli.Run("core", "search")
require.NoError(t, err)
var lines [][]string
for _, v := range strings.Split(strings.TrimSpace(string(stdout)), "\n") {
lines = append(lines, strings.Fields(strings.TrimSpace(v)))
}
// The header is printed on the first lines
require.Equal(t, []string{"test:x86", "2.0.0", "test_core"}, lines[19])
// We use black to format and flake8 to lint .py files but they disagree on certain
// things like this one, thus we ignore this specific flake8 rule and stand by black
// opinion.
// We ignore this specific case because ignoring it globally would probably cause more
// issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
numPlatforms := len(lines) - 1 // noqa: E203

// same thing in JSON format, also check the number of platforms found is the same
stdout, _, err = cli.Run("core", "search", "--format", "json")
require.NoError(t, err)
requirejson.Query(t, stdout, " .[] | select(.name == \"test_core\") | . != \"\"", "true")
requirejson.Query(t, stdout, "length", fmt.Sprint(numPlatforms))

// list all with additional urls, check the test core is there
stdout, _, err = cli.Run("core", "search", "--additional-urls="+url.String())
require.NoError(t, err)
lines = nil
for _, v := range strings.Split(strings.TrimSpace(string(stdout)), "\n") {
lines = append(lines, strings.Fields(strings.TrimSpace(v)))
}
// The header is printed on the first lines
require.Equal(t, []string{"test:x86", "2.0.0", "test_core"}, lines[20])
// We use black to format and flake8 to lint .py files but they disagree on certain
// things like this one, thus we ignore this specific flake8 rule and stand by black
// opinion.
// We ignore this specific case because ignoring it globally would probably cause more
// issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
numPlatforms = len(lines) - 1 // noqa: E203

// same thing in JSON format, also check the number of platforms found is the same
stdout, _, err = cli.Run("core", "search", "--format", "json", "--additional-urls="+url.String())
require.NoError(t, err)
requirejson.Query(t, stdout, " .[] | select(.name == \"test_core\") | . != \"\"", "true")
requirejson.Query(t, stdout, "length", fmt.Sprint(numPlatforms))
}
59 changes: 0 additions & 59 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,65 +26,6 @@
import semver


def test_core_search_no_args(run_command, httpserver):
"""
This tests `core search` with and without additional URLs in case no args
are passed (i.e. all results are shown).
"""
# Set up the server to serve our custom index file
test_index = Path(__file__).parent / "testdata" / "test_index.json"
httpserver.expect_request("/test_index.json").respond_with_data(test_index.read_text())

# update custom index and install test core (installed cores affect `core search`)
url = httpserver.url_for("/test_index.json")
assert run_command(["core", "update-index", f"--additional-urls={url}"])
assert run_command(["core", "install", "test:x86", f"--additional-urls={url}"])

# list all with no additional urls, ensure the test core won't show up
result = run_command(["core", "search"])
assert result.ok
num_platforms = 0
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
# The header is printed on the first lines
assert ["test:x86", "2.0.0", "test_core"] in lines
header_index = lines.index(["ID", "Version", "Name"])
# We use black to format and flake8 to lint .py files but they disagree on certain
# things like this one, thus we ignore this specific flake8 rule and stand by black
# opinion.
# We ignore this specific case because ignoring it globally would probably cause more
# issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
num_platforms = len(lines[header_index + 1 :]) # noqa: E203

# same thing in JSON format, also check the number of platforms found is the same
result = run_command(["core", "search", "--format", "json"])
assert result.ok
platforms = json.loads(result.stdout)
assert 1 == len([e for e in platforms if e.get("name") == "test_core"])
assert len(platforms) == num_platforms

# list all with additional urls, check the test core is there
result = run_command(["core", "search", f"--additional-urls={url}"])
assert result.ok
num_platforms = 0
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
# The header is printed on the first lines
assert ["test:x86", "2.0.0", "test_core"] in lines
header_index = lines.index(["ID", "Version", "Name"])
# We use black to format and flake8 to lint .py files but they disagree on certain
# things like this one, thus we ignore this specific flake8 rule and stand by black
# opinion.
# We ignore this specific case because ignoring it globally would probably cause more
# issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
num_platforms = len(lines[header_index + 1 :]) # noqa: E203

# same thing in JSON format, also check the number of platforms found is the same
result = run_command(["core", "search", "--format", "json", f"--additional-urls={url}"])
assert result.ok
platforms = json.loads(result.stdout)
assert 1 == len([e for e in platforms if e.get("name") == "test_core"])
assert len(platforms) == num_platforms


def test_core_updateindex_url_not_found(run_command, httpserver):
assert run_command(["core", "update-index"])

Expand Down