-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest-update-server.js
More file actions
63 lines (56 loc) · 1.79 KB
/
test-update-server.js
File metadata and controls
63 lines (56 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const express = require('express')
const app = express()
const port = 3001
// Mock update info that triggers an update
const mockUpdateInfo = {
name: '2025.12.31-dev.999', // Higher version than current
release_notes: 'Test update for debugging auto-update process',
assets: {
linux: {
deb: {
download_url: 'http://localhost:3001/fake-download.deb',
size: 1024000
},
rpm: {
download_url: 'http://localhost:3001/fake-download.rpm',
size: 1024000
}
},
macos: {
x64: {
download_url: 'http://localhost:3001/fake-download-x64.zip',
zip_url: 'http://localhost:3001/fake-download-x64.zip',
size: 1024000
},
arm64: {
download_url: 'http://localhost:3001/fake-download-arm64.zip',
zip_url: 'http://localhost:3001/fake-download-arm64.zip',
size: 1024000
}
},
windows: {
exe: {
download_url: 'http://localhost:3001/fake-download.exe',
size: 1024000
}
}
}
}
app.get('/latest.json', (req, res) => {
console.log('Update check requested')
res.json(mockUpdateInfo)
})
// Mock download endpoints that create fake files
app.get('/fake-download.*', (req, res) => {
console.log(`Mock download requested: ${req.path}`)
// Create a small fake file content
const fakeFileContent = Buffer.alloc(1024, 'fake installer data')
res.setHeader('Content-Type', 'application/octet-stream')
res.setHeader('Content-Length', fakeFileContent.length)
res.setHeader('Content-Disposition', `attachment; filename="${req.path.substring(1)}"`)
res.send(fakeFileContent)
})
app.listen(port, () => {
console.log(`Mock update server running at http://localhost:${port}`)
console.log('Use this URL for testing: http://localhost:3001/latest.json')
})