Skip to content

Commit

Permalink
Add corrupted json test
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoPologruto committed Aug 5, 2024
1 parent 650622b commit b5adf5f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,22 @@ func TestDownload(t *testing.T) {
})
}
}

func TestCorruptedInstalledJson(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")

Check failure on line 172 in tools/download_test.go

View workflow job for this annotation

GitHub Actions / check-style (./)

var corruptedJson should be corruptedJSON
fileJson, err := corruptedJson.Create()

Check failure on line 173 in tools/download_test.go

View workflow job for this annotation

GitHub Actions / check-style (./)

var fileJson should be fileJSON
require.NoError(t, err)
_, 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)
}

0 comments on commit b5adf5f

Please sign in to comment.