Skip to content

Improve installed.json handling in v2/tools #983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add corrupted json test
  • Loading branch information
MatteoPologruto committed Aug 5, 2024
commit 33f59b544056dacf9597f885b64b091a4f2d049c
20 changes: 20 additions & 0 deletions tools/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,23 @@ func TestDownload(t *testing.T) {
})
}
}

func TestCorruptedInstalled(t *testing.T) {
// prepare the test environment
tempDir := t.TempDir()
tempDirPath := paths.New(tempDir)
testIndex := index.Resource{
IndexFile: *paths.New("testdata", "test_tool_index.json"),
LastRefresh: time.Now(),
}
corruptedJSON := tempDirPath.Join("installed.json")
fileJSON, err := corruptedJSON.Create()
require.NoError(t, err)
defer fileJSON.Close()
_, err = fileJSON.Write([]byte("Hello"))
require.NoError(t, err)
testTools := New(tempDirPath, &testIndex, func(msg string) { t.Log(msg) })
// Download the tool
err = testTools.Download("arduino-test", "avrdude", "6.3.0-arduino17", "keep")
require.NoError(t, err)
}