forked from electron/update.electronjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve unit tests (electron#126)
Co-authored-by: Felix Rieseberg <[email protected]>
- Loading branch information
1 parent
7bd992d
commit 8eec1fa
Showing
7 changed files
with
136 additions
and
76 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,32 @@ | ||
const { PLATFORM_ARCH } = require("./constants"); | ||
|
||
const assetPlatform = (fileName) => { | ||
if (/.*(mac|darwin|osx).*(-arm).*\.zip/i.test(fileName)) { | ||
return PLATFORM_ARCH.DARWIN_ARM64; | ||
} | ||
|
||
if (/.*(mac|darwin|osx).*\.zip/i.test(fileName) && !/arm64/.test(fileName)) { | ||
return PLATFORM_ARCH.DARWIN_X64; | ||
} | ||
|
||
if (/win32-ia32/.test(fileName)) return PLATFORM_ARCH.WIN_IA32; | ||
if (/win32-x64/.test(fileName)) return PLATFORM_ARCH.WIN_X64; | ||
if (/win32-arm64/.test(fileName)) return PLATFORM_ARCH.WIN_ARM64; | ||
|
||
// Special case handling: We don't know what kind of asset | ||
// we're looking at, so it might be the default x64 windows | ||
// asset | ||
if ( | ||
/\.exe$/.test(fileName) && | ||
!/arm/.test(fileName) && | ||
!/ia32/.test(fileName) | ||
) { | ||
return PLATFORM_ARCH.WIN_X64; | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
module.exports = { | ||
assetPlatform, | ||
}; |
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,20 @@ | ||
const PLATFORM = { | ||
WIN32: "win32", | ||
DARWIN: "darwin", | ||
}; | ||
|
||
const PLATFORM_ARCH = { | ||
DARWIN_X64: "darwin-x64", | ||
DARWIN_ARM64: "darwin-arm64", | ||
WIN_X64: "win32-x64", | ||
WIN_IA32: "win32-ia32", | ||
WIN_ARM64: "win32-arm64", | ||
}; | ||
|
||
const PLATFORM_ARCHS = Object.values(PLATFORM_ARCH); | ||
|
||
module.exports = { | ||
PLATFORM, | ||
PLATFORM_ARCH, | ||
PLATFORM_ARCHS, | ||
}; |
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,42 @@ | ||
const { test } = require("tap"); | ||
const { assetPlatform } = require("../src/asset-platform"); | ||
|
||
const { PLATFORM_ARCH } = require("../src/constants"); | ||
|
||
test("assetPlatform() matches the right platform", (t) => { | ||
const releases = [ | ||
{ name: "electron-fiddle-0.27.3-1.arm64.rpm", platform: false }, | ||
{ name: "electron-fiddle-0.27.3-1.armv7hl.rpm", platform: false }, | ||
{ name: "electron-fiddle-0.27.3-1.x86_64.rpm", platform: false }, | ||
{ name: "electron-fiddle-0.27.3-full.nupkg", platform: false }, | ||
{ | ||
name: "electron-fiddle-0.27.3-win32-arm64-setup.exe", | ||
platform: PLATFORM_ARCH.WIN_ARM64, | ||
}, | ||
{ | ||
name: "electron-fiddle-0.27.3-win32-ia32-setup.exe", | ||
platform: PLATFORM_ARCH.WIN_IA32, | ||
}, | ||
{ | ||
name: "electron-fiddle-0.27.3-win32-x64-setup.exe", | ||
platform: PLATFORM_ARCH.WIN_X64, | ||
}, | ||
{ name: "electron-fiddle_0.27.3_amd64.deb", platform: false }, | ||
{ name: "electron-fiddle_0.27.3_arm64.deb", platform: false }, | ||
{ name: "electron-fiddle_0.27.3_armhf.deb", platform: false }, | ||
{ | ||
name: "Electron.Fiddle-darwin-arm64-0.27.3.zip", | ||
platform: PLATFORM_ARCH.DARWIN_ARM64, | ||
}, | ||
{ | ||
name: "Electron.Fiddle-darwin-x64-0.27.3.zip", | ||
platform: PLATFORM_ARCH.DARWIN_X64, | ||
}, | ||
]; | ||
|
||
for (const release of releases) { | ||
t.equal(assetPlatform(release.name), release.platform); | ||
} | ||
|
||
t.end(); | ||
}); |
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