Skip to content

Commit 33f59b5

Browse files
Add corrupted json test
1 parent 650622b commit 33f59b5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tools/download_test.go

+20
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,23 @@ func TestDownload(t *testing.T) {
160160
})
161161
}
162162
}
163+
164+
func TestCorruptedInstalled(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+
defer fileJSON.Close()
176+
_, err = fileJSON.Write([]byte("Hello"))
177+
require.NoError(t, err)
178+
testTools := New(tempDirPath, &testIndex, func(msg string) { t.Log(msg) })
179+
// Download the tool
180+
err = testTools.Download("arduino-test", "avrdude", "6.3.0-arduino17", "keep")
181+
require.NoError(t, err)
182+
}

0 commit comments

Comments
 (0)