Skip to content

Commit 83554ba

Browse files
Add TestCoreBrokenDependency to core_test.go
1 parent a8007b8 commit 83554ba

File tree

2 files changed

+53
-4
lines changed

2 files changed

+53
-4
lines changed

Diff for: internal/integrationtest/core/core_test.go

+21-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestCoreSearch(t *testing.T) {
8080
// show all versions
8181
out, _, err = cli.Run("core", "search", "test_core", "--all", "--format", "json", "--additional-urls="+url.String())
8282
require.NoError(t, err)
83-
requirejson.Len(t, out, 2)
83+
requirejson.Len(t, out, 3)
8484

8585
checkPlatformIsInJSONOutput := func(stdout []byte, id, version string) {
8686
jqquery := fmt.Sprintf(`[{id:"%s", latest:"%s"}]`, id, version)
@@ -150,7 +150,7 @@ func TestCoreSearchNoArgs(t *testing.T) {
150150
// update custom index and install test core (installed cores affect `core search`)
151151
_, _, err := cli.Run("core", "update-index", "--additional-urls="+url.String())
152152
require.NoError(t, err)
153-
_, _, err = cli.Run("core", "install", "test:x86", "--additional-urls="+url.String())
153+
_, _, err = cli.Run("core", "install", "test:x86@2.0.0", "--additional-urls="+url.String())
154154
require.NoError(t, err)
155155

156156
// list all with no additional urls, ensure the test core won't show up
@@ -725,7 +725,7 @@ func TestCoreListSortedResults(t *testing.T) {
725725
require.NoError(t, err)
726726

727727
// install some core for testing
728-
_, _, err = cli.Run("core", "install", "test:x86", "Retrokits-RK002:arm", "Package:x86", "--additional-urls="+url.String())
728+
_, _, err = cli.Run("core", "install", "test:x86@2.0.0", "Retrokits-RK002:arm", "Package:x86", "--additional-urls="+url.String())
729729
require.NoError(t, err)
730730

731731
// list all with additional url specified
@@ -1006,3 +1006,21 @@ func TestCoreInstallRunsToolPostInstallScript(t *testing.T) {
10061006
require.NoError(t, err)
10071007
require.Contains(t, string(stdout), "Skipping tool configuration.")
10081008
}
1009+
1010+
func TestCoreBrokenDependency(t *testing.T) {
1011+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
1012+
defer env.CleanUp()
1013+
1014+
// Set up an http server to serve our custom index file
1015+
test_index := paths.New("..", "testdata", "test_index.json")
1016+
url := env.HTTPServeFile(8000, test_index)
1017+
1018+
// Run update-index with our test index
1019+
_, _, err := cli.Run("core", "update-index", "--additional-urls="+url.String())
1020+
require.NoError(t, err)
1021+
1022+
// Check that the download fails and the correct message is displayed
1023+
_, stderr, err := cli.Run("core", "install", "test:[email protected]", "--additional-urls="+url.String())
1024+
require.Error(t, err)
1025+
require.Contains(t, string(stderr), "try contacting [email protected]")
1026+
}

Diff for: internal/integrationtest/testdata/test_index.json

+32-1
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,40 @@
4444
"name": "Test Board"
4545
}
4646
]
47+
},
48+
{
49+
"category": "Test Category",
50+
"help": {
51+
"online": "https://github.com/Arduino/arduino-cli"
52+
},
53+
"url": "https://raw.githubusercontent.com/arduino/arduino-cli/master/internal/integrationtest/testdata/core.zip",
54+
"checksum": "SHA-256:6a338cf4d6d501176a2d352c87a8d72ac7488b8c5b82cdf2a4e2cef630391092",
55+
"name": "test_core",
56+
"version": "3.0.0",
57+
"architecture": "x86",
58+
"archiveFileName": "core.zip",
59+
"size": "486",
60+
"toolsDependencies": [
61+
{
62+
"packager": "test",
63+
"version": "1.0.6",
64+
"name": "rp2040tools"
65+
}
66+
],
67+
"boards": [
68+
{
69+
"name": "Test Board"
70+
}
71+
]
72+
}
73+
],
74+
"tools": [
75+
{
76+
"name": "rp2040tools",
77+
"version": "1.0.6",
78+
"systems": []
4779
}
4880
],
49-
"tools": [],
5081
"email": "[email protected]",
5182
"name": "test"
5283
},

0 commit comments

Comments
 (0)