Skip to content

Commit 6755fe6

Browse files
Migrate TestUpdateWithUrlInternalServerError from test_update.py to update_test.go
1 parent c2e8fb1 commit 6755fe6

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
@@ -112,3 +112,18 @@ func TestUpdateWithUrlNotFound(t *testing.T) {
112112
require.Error(t, err)
113113
require.Contains(t, string(stdout), "Downloading index: test_index.json Server responded with: 404 Not Found")
114114
}
115+
116+
func TestUpdateWithUrlInternalServerError(t *testing.T) {
117+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
118+
defer env.CleanUp()
119+
120+
_, _, err := cli.Run("update")
121+
require.NoError(t, err)
122+
123+
// Brings up a local server to fake a failure
124+
url := serveFileWithCode(8080, "test_index.json", 500, env)
125+
126+
stdout, _, err := cli.Run("update", "--additional-urls="+url.String())
127+
require.Error(t, err)
128+
require.Contains(t, string(stdout), "Downloading index: test_index.json Server responded with: 500 Internal Server Error")
129+
}

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)