Skip to content

Commit

Permalink
Fix tests: additional core urls
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed May 13, 2019
1 parent 584d657 commit 9fc2db6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,12 @@ func TestInvalidCoreURL(t *testing.T) {
defer tmp.RemoveAll()

configFile := tmp.Join("cli-config.yml")
configFile.WriteFile([]byte(`
err = configFile.WriteFile([]byte(`
board_manager:
additional_urls:
- http://www.example.com/package_example_index.json
- http://www.invalid-domain-asjkdakdhadjkh.com/package_example_index.json
`))
require.NoError(t, err, "writing dummy config "+configFile.String())

require.NoError(t, currDataDir.MkdirAll())
err = currDataDir.Join("package_index.json").WriteFile([]byte(`{ "packages": [] }`))
Expand All @@ -564,7 +565,12 @@ board_manager:
require.Zero(t, exitCode, "exit code")
require.Empty(t, strings.TrimSpace(string(d)))

// Empty cores list
// Dump config with cmd-line specific file
exitCode, d = executeWithArgs(t, "--config-file", configFile.String(), "config", "dump")
require.Zero(t, exitCode, "exit code")
require.Contains(t, string(d), "- http://www.invalid-domain-asjkdakdhadjkh.com/package_example_index.json")

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

Expand Down
2 changes: 1 addition & 1 deletion cli/core/update_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func initUpdateIndexCommand() *cobra.Command {
}

func runUpdateIndexCommand(cmd *cobra.Command, args []string) {
instance := cli.InitInstance(false).GetInstance()
instance := cli.CreateInstance()
logrus.Info("Executing `arduino core update-index`")

_, err := commands.UpdateIndex(context.Background(), &rpc.UpdateIndexReq{
Expand Down
2 changes: 2 additions & 0 deletions commands/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ func Init(ctx context.Context, req *rpc.InitReq) (*rpc.InitResp, error) {
return nil, fmt.Errorf("parsing url %s: %s", rawurl, err)
}
}
config.BoardManagerAdditionalUrls = urls

pm, lm, reqPltIndex, reqLibIndex, err := createInstance(ctx, config, req.GetLibraryManagerOnly())
if err != nil {
return nil, fmt.Errorf("cannot initialize package manager: %s", err)
Expand Down

0 comments on commit 9fc2db6

Please sign in to comment.