Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b2dc757

Browse files
committedNov 9, 2022
Migrate TestCoreUpdateIndexInternalServerError from test_core.py to core_test.go
1 parent d7f0727 commit b2dc757

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed
 

‎internal/integrationtest/core/core_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,18 @@ func TestCoreUpdateIndexUrlNotFound(t *testing.T) {
204204
require.Contains(t, string(stdout), "Downloading index: test_index.json Server responded with: 404 Not Found")
205205
require.Contains(t, string(stderr), "Some indexes could not be updated.")
206206
}
207+
208+
func TestCoreUpdateIndexInternalServerError(t *testing.T) {
209+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
210+
defer env.CleanUp()
211+
212+
_, _, err := cli.Run("core", "update-index")
213+
require.NoError(t, err)
214+
215+
// Brings up a local server to fake a failure
216+
url := env.HTTPServeFileError(8000, paths.New("test_index.json"), 500)
217+
218+
stdout, _, err := cli.Run("core", "update-index", "--additional-urls="+url.String())
219+
require.Error(t, err)
220+
require.Contains(t, string(stdout), "Downloading index: test_index.json Server responded with: 500 Internal Server Error")
221+
}

‎test/test_core.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,6 @@
2626
import semver
2727

2828

29-
def test_core_updateindex_internal_server_error(run_command, httpserver):
30-
assert run_command(["core", "update-index"])
31-
32-
# Brings up a local server to fake a failure
33-
httpserver.expect_request("/test_index.json").respond_with_data(status=500)
34-
url = httpserver.url_for("/test_index.json")
35-
36-
result = run_command(["core", "update-index", f"--additional-urls={url}"])
37-
assert result.failed
38-
lines = [l.strip() for l in result.stdout.splitlines()]
39-
assert "Downloading index: test_index.json Server responded with: 500 INTERNAL SERVER ERROR" in lines
40-
41-
4229
def test_core_install_without_updateindex(run_command):
4330
# Missing "core update-index"
4431
# Download samd core pinned to 1.8.6

0 commit comments

Comments
 (0)
Please sign in to comment.