-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better handling of platforms when downloading
Check whether platform is supported before moving on Add some tests to ensure it's the case. Also that we support all said platform (file can actually be downloaded). This test suite is slow, but I think it's worth it Note: in future releases, windows support will need to be reworked. in some instances, the `exe` is gone and replaced with a zip that'll likely need to unpack
- Loading branch information
1 parent
78f484f
commit 7a1d861
Showing
3 changed files
with
56 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { downloadCoursierIfRequired } from "../../src/coursier/download-coursier"; | ||
import { tmpdir } from "os"; | ||
import { existsSync, mkdirSync, accessSync, constants, rmSync } from "fs"; | ||
import { join } from "path"; | ||
|
||
["darwin", "linux", "win32"].forEach((p) => { | ||
test( | ||
`download on platform: ${p}`, | ||
() => { | ||
const dir = join(tmpdir(), p); | ||
rmSync(dir, { recursive: true, force: true }); | ||
mkdirSync(dir, { recursive: true }); | ||
return downloadCoursierIfRequired(dir, p, "v2.0.13").then((x) => { | ||
expect(existsSync(x)).toBeTruthy(); | ||
accessSync(x, constants.X_OK); | ||
}); | ||
}, | ||
25 * 1000 | ||
); | ||
}); | ||
|
||
test(`fails on unknown platform`, () => { | ||
return expect( | ||
downloadCoursierIfRequired(tmpdir(), "unsupported", "v2.0.13") | ||
).rejects.toEqual("Unsupported platform unsupported."); | ||
}); |