8000 Installer improvements by cmaglie · Pull Request #89 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content

Installer improvements #89

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 6 commits into from
Nov 9, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added tests for invalid 3rd-party URL
as explained in #81:

  It says all packages were downloaded:

    Updating index: package_index.json downloaded
    Updating index: package_esp8266com_index.json downloaded
    Updating index: package_lalala_index.json downloaded

  But when you run commands like arduino-cli core list or arduino-cli board listall it exits with an error:

    Error: loading json index file /Users/MY_USER_NAME/arduino-cli/data/package_lalala_index.json: invalid character '<' looking for beginning of value
    Failed to load http://google.com/package_lalala_index.json package index.
    Try updating all indexes with `arduino-cli core update-index`.

  It occurs, because package_lalala_index.json contains 404 HTML page.
  • Loading branch information
cmaglie committed Nov 8, 2018
commit 917b9e2564851f3ad81f13c2ff7be98abd6b4239
36 changes: 36 additions & 0 deletions commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,42 @@ func TestCompileCommands(t *testing.T) {
require.True(t, paths.New("anothertest", "test2.hex").Exist())
}

func TestInvalidCoreURL(t *testing.T) {
defer makeTempDataDir(t)()
defer makeTempSketchbookDir(t)()

tmp, err := paths.MkTempDir("", "")
require.NoError(t, err, "making temporary dir")
defer tmp.RemoveAll()

configFile := tmp.Join("cli-config.yml")
configFile.WriteFile([]byte(`
board_manager:
additional_urls:
- http://www.example.com/package_example_index.json
`))

require.NoError(t, currDataDir.MkdirAll())
err = currDataDir.Join("package_index.json").WriteFile([]byte(`{ "packages": [] }`))
require.NoError(t, err, "Writing empty json index file")
err = currDataDir.Join("package_example_index.json").WriteFile([]byte(`{ "packages": [] }`))
require.NoError(t, err, "Writing empty json index file")

// Empty cores list
exitCode, d := executeWithArgs(t, "--config-file", configFile.String(), "core", "list")
require.Zero(t, exitCode, "exit code")
require.Empty(t, strings.TrimSpace(string(d)))

// Empty cores list
exitCode, _ = executeWithArgs(t, "--config-file", configFile.String(), "core", "update-index")
require.NotZero(t, exitCode, "exit code")

// Empty cores list
exitCode, d = executeWithArgs(t, "--config-file", configFile.String(), "core", "list")
require.Zero(t, exitCode, "exit code")
require.Empty(t, strings.TrimSpace(string(d)))
}

func TestCoreCommands(t *testing.T) {
defer makeTempDataDir(t)()
defer makeTempSketchbookDir(t)()
Expand Down
0