Skip to content

Commit 66ce6f8

Browse files
committed
configs: Correctly override board manager additional urls
1 parent 5c48c84 commit 66ce6f8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

commands/commands_test.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ func executeWithArgs(t *testing.T, args ...string) (int, []byte) {
7474

7575
// This closure is here because we won't that the defer are executed after the end of the "executeWithArgs" method
7676
func() {
77+
// Create an empty config for the CLI test
78+
conf := paths.New("arduino-cli.yaml")
79+
require.False(t, conf.Exist())
80+
err := conf.WriteFile([]byte("board_manager:\n additional_urls:\n"))
81+
require.NoError(t, err)
82+
defer func() {
83+
require.NoError(t, conf.Remove())
84+
}()
85+
7786
redirect := &stdOutRedirect{}
7887
redirect.Open(t)
7988
defer func() {
@@ -544,7 +553,7 @@ func TestInvalidCoreURL(t *testing.T) {
544553
require.NoError(t, err, "making temporary dir")
545554
defer tmp.RemoveAll()
546555

547-
configFile := tmp.Join("cli-config.yml")
556+
configFile := tmp.Join("arduino-cli.yaml")
548557
configFile.WriteFile([]byte(`
549558
board_manager:
550559
additional_urls:

configs/yaml_serializer.go

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ func (config *Configuration) LoadFromYAML(path *paths.Path) error {
7777
}
7878
}
7979
if ret.BoardsManager != nil {
80+
if len(config.BoardManagerAdditionalUrls) > 1 {
81+
config.BoardManagerAdditionalUrls = config.BoardManagerAdditionalUrls[:1]
82+
}
8083
for _, rawurl := range ret.BoardsManager.AdditionalURLS {
8184
url, err := url.Parse(rawurl)
8285
if err != nil {

0 commit comments

Comments
 (0)