Skip to content

Commit d48e80b

Browse files
Migrate TestUpdateWithUrlNotFound from test_update.py to update_test.go
1 parent 75dc39d commit d48e80b

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

internal/integrationtest/update/update_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"testing"
2121

2222
"github.com/arduino/arduino-cli/internal/integrationtest"
23+
"github.com/arduino/go-paths-helper"
2324
"github.com/stretchr/testify/require"
2425
)
2526

@@ -68,3 +69,18 @@ func TestUpdateShowingOutdated(t *testing.T) {
6869
require.True(t, strings.HasPrefix(lines[3], "Arduino AVR Boards"))
6970
require.True(t, strings.HasPrefix(lines[6], "USBHost"))
7071
}
72+
73+
func TestUpdateWithUrlNotFound(t *testing.T) {
74+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
75+
defer env.CleanUp()
76+
77+
_, _, err := cli.Run("update")
78+
require.NoError(t, err)
79+
80+
// Brings up a local server to fake a failure
81+
url := env.HTTPServeFileError(8000, paths.New("test_index.json"), 404)
82+
83+
stdout, _, err := cli.Run("update", "--additional-urls="+url.String())
84+
require.Error(t, err)
85+
require.Contains(t, string(stdout), "Downloading index: test_index.json Server responded with: 404 Not Found")
86+
}

test/test_update.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@
1616
from pathlib import Path
1717

1818

19-
def test_update_with_url_not_found(run_command, httpserver):
20-
assert run_command(["update"])
21-
22-
# Brings up a local server to fake a failure
23-
httpserver.expect_request("/test_index.json").respond_with_data(status=404)
24-
url = httpserver.url_for("/test_index.json")
25-
26-
res = run_command(["update", f"--additional-urls={url}"])
27-
assert res.failed
28-
lines = [l.strip() for l in res.stdout.splitlines()]
29-
assert "Downloading index: test_index.json Server responded with: 404 NOT FOUND" in lines
30-
31-
3219
def test_update_with_url_internal_server_error(run_command, httpserver):
3320
assert run_command(["update"])
3421

0 commit comments

Comments
 (0)