Skip to content

Commit b5adf5f

Browse files
Add corrupted json test
1 parent 650622b commit b5adf5f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/download_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,22 @@ func TestDownload(t *testing.T) {
160160
})
161161
}
162162
}
163+
164+
func TestCorruptedInstalledJson(t *testing.T) {
165+
// prepare the test environment
166+
tempDir := t.TempDir()
167+
tempDirPath := paths.New(tempDir)
168+
testIndex := index.Resource{
169+
IndexFile: *paths.New("testdata", "test_tool_index.json"),
170+
LastRefresh: time.Now(),
171+
}
172+
corruptedJson := tempDirPath.Join("installed.json")
173+
fileJson, err := corruptedJson.Create()
174+
require.NoError(t, err)
175+
_, err = fileJson.Write([]byte("Hello"))
176+
require.NoError(t, err)
177+
testTools := New(tempDirPath, &testIndex, func(msg string) { t.Log(msg) })
178+
// Download the tool
179+
err = testTools.Download("arduino-test", "avrdude", "6.3.0-arduino17", "keep")
180+
require.NoError(t, err)
181+
}

0 commit comments

Comments
 (0)