spec: add tests for the autoUpdater on macOS that actually test if it works (#17442)
* spec: add tests for the autoUpdater on macOS that actually test if it works * spec: add express as dep * spec: add logic to auto-trust self-signed certificate and not run autoupdate specs on MAS * build: fix the step name for importing the codesign cert * chore: update updater spec PR as per feedback * fix: s/atomBinding/electronBinding * build: use spawn instead of exec
This commit is contained in:
parent
5045b0a962
commit
b8dbe4bc15
21 changed files with 923 additions and 48 deletions
42
spec/fixtures/auto-update/update/index.js
vendored
Normal file
42
spec/fixtures/auto-update/update/index.js
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
process.on('uncaughtException', (err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
const { app, autoUpdater } = require('electron')
|
||||
|
||||
autoUpdater.on('error', (err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
const urlPath = path.resolve(__dirname, '../../../../url.txt')
|
||||
let feedUrl = process.argv[1]
|
||||
if (!feedUrl || !feedUrl.startsWith('http')) {
|
||||
feedUrl = `${fs.readFileSync(urlPath, 'utf8')}/${app.getVersion()}`
|
||||
} else {
|
||||
fs.writeFileSync(urlPath, `${feedUrl}/updated`)
|
||||
}
|
||||
|
||||
autoUpdater.setFeedURL({
|
||||
url: feedUrl
|
||||
})
|
||||
|
||||
autoUpdater.checkForUpdates()
|
||||
|
||||
autoUpdater.on('update-available', () => {
|
||||
console.log('Update Available')
|
||||
})
|
||||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
console.log('Update Downloaded')
|
||||
autoUpdater.quitAndInstall()
|
||||
})
|
||||
|
||||
autoUpdater.on('update-not-available', () => {
|
||||
console.error('No update available')
|
||||
process.exit(1)
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue