Skip to content

Commit d7f0727

Browse files
Migrate TestCoreUpdateIndexUrlNotFound from test_core.py to core_test.go
1 parent 47eebca commit d7f0727

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

internal/integrationtest/core/core_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,19 @@ func TestCoreSearchNoArgs(t *testing.T) {
188188
requirejson.Query(t, stdout, " .[] | select(.name == \"test_core\") | . != \"\"", "true")
189189
requirejson.Query(t, stdout, "length", fmt.Sprint(numPlatforms))
190190
}
191+
192+
func TestCoreUpdateIndexUrlNotFound(t *testing.T) {
193+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
194+
defer env.CleanUp()
195+
196+
_, _, err := cli.Run("core", "update-index")
197+
require.NoError(t, err)
198+
199+
// Brings up a local server to fake a failure
200+
url := env.HTTPServeFileError(8000, paths.New("test_index.json"), 404)
201+
202+
stdout, stderr, err := cli.Run("core", "update-index", "--additional-urls="+url.String())
203+
require.Error(t, err)
204+
require.Contains(t, string(stdout), "Downloading index: test_index.json Server responded with: 404 Not Found")
205+
require.Contains(t, string(stderr), "Some indexes could not be updated.")
206+
}

test/test_core.py

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

2828

29-
def test_core_updateindex_url_not_found(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=404)
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-
linesout = [l.strip() for l in result.stdout.splitlines()]
39-
assert "Downloading index: test_index.json Server responded with: 404 NOT FOUND" in linesout
40-
lineserr = [l.strip() for l in result.stderr.splitlines()]
41-
assert "Some indexes could not be updated." in lineserr
42-
43-
4429
def test_core_updateindex_internal_server_error(run_command, httpserver):
4530
assert run_command(["core", "update-index"])
4631

0 commit comments

Comments
 (0)