Skip to content

Commit 79516ef

Browse files
Migrate TestUpdateWithUrlInternalServerError from test_update.py to update_test.go
1 parent d48e80b commit 79516ef

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

internal/integrationtest/update/update_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,18 @@ func TestUpdateWithUrlNotFound(t *testing.T) {
8484
require.Error(t, err)
8585
require.Contains(t, string(stdout), "Downloading index: test_index.json Server responded with: 404 Not Found")
8686
}
87+
88+
func TestUpdateWithUrlInternalServerError(t *testing.T) {
89+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
90+
defer env.CleanUp()
91+
92+
_, _, err := cli.Run("update")
93+
require.NoError(t, err)
94+
95+
// Brings up a local server to fake a failure
96+
url := env.HTTPServeFileError(8000, paths.New("test_index.json"), 500)
97+
98+
stdout, _, err := cli.Run("update", "--additional-urls="+url.String())
99+
require.Error(t, err)
100+
require.Contains(t, string(stdout), "Downloading index: test_index.json Server responded with: 500 Internal Server Error")
101+
}

test/test_update.py

-13
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_internal_server_error(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=500)
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: 500 INTERNAL SERVER ERROR" in lines
30-
31-
3219
def test_update_showing_outdated_using_library_with_invalid_version(run_command, data_dir):
3320
assert run_command(["update"])
3421

0 commit comments

Comments
 (0)