mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-16 10:28:29 -07:00
Merge: * auto-update: use backup directory format without version: "agh-backup"
Close #801 * commit '885b660808a848277f080c78dc7e6107afdbabb7': * auto-update: refactor test; test getUpdateInfo() * auto-update: use backup directory format without version: "agh-backup"
This commit is contained in:
commit
b45e8e80fb
@ -164,7 +164,7 @@ func getUpdateInfo(jsonData []byte) (*updateInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u.updateDir = filepath.Join(workDir, fmt.Sprintf("agh-update-%s", u.newVer))
|
u.updateDir = filepath.Join(workDir, fmt.Sprintf("agh-update-%s", u.newVer))
|
||||||
u.backupDir = filepath.Join(workDir, fmt.Sprintf("agh-backup-%s", versionString))
|
u.backupDir = filepath.Join(workDir, "agh-backup")
|
||||||
|
|
||||||
_, pkgFileName := filepath.Split(u.pkgURL)
|
_, pkgFileName := filepath.Split(u.pkgURL)
|
||||||
if len(pkgFileName) == 0 {
|
if len(pkgFileName) == 0 {
|
||||||
|
@ -8,20 +8,57 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestDoUpdate(t *testing.T) {
|
func TestDoUpdate(t *testing.T) {
|
||||||
|
|
||||||
config.DNS.Port = 0
|
config.DNS.Port = 0
|
||||||
config.ourWorkingDir = "."
|
config.ourWorkingDir = "..." // set absolute path
|
||||||
u := updateInfo{
|
newver := "v0.96"
|
||||||
pkgURL: "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.95/AdGuardHome_v0.95_linux_amd64.tar.gz",
|
|
||||||
pkgName: "./AdGuardHome_v0.95_linux_amd64.tar.gz",
|
data := `{
|
||||||
newVer: "v0.95",
|
"version": "v0.96",
|
||||||
updateDir: "./agh-update-v0.95",
|
"announcement": "AdGuard Home v0.96 is now available!",
|
||||||
backupDir: "./agh-backup-v0.94",
|
"announcement_url": "",
|
||||||
configName: "./AdGuardHome.yaml",
|
"download_windows_amd64": "",
|
||||||
updateConfigName: "./agh-update-v0.95/AdGuardHome/AdGuardHome.yaml",
|
"download_windows_386": "",
|
||||||
curBinName: "./AdGuardHome",
|
"download_darwin_amd64": "",
|
||||||
bkpBinName: "./agh-backup-v0.94/AdGuardHome",
|
"download_linux_amd64": "https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.96/AdGuardHome_linux_amd64.tar.gz",
|
||||||
newBinName: "./agh-update-v0.95/AdGuardHome/AdGuardHome",
|
"download_linux_386": "",
|
||||||
|
"download_linux_arm": "",
|
||||||
|
"download_linux_arm64": "",
|
||||||
|
"download_linux_mips": "",
|
||||||
|
"download_linux_mipsle": "",
|
||||||
|
"selfupdate_min_version": "v0.0"
|
||||||
|
}`
|
||||||
|
uu, err := getUpdateInfo([]byte(data))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("getUpdateInfo: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u := updateInfo{
|
||||||
|
pkgURL: "https://github.com/AdguardTeam/AdGuardHome/releases/download/" + newver + "/AdGuardHome_linux_amd64.tar.gz",
|
||||||
|
pkgName: config.ourWorkingDir + "/agh-update-" + newver + "/AdGuardHome_linux_amd64.tar.gz",
|
||||||
|
newVer: newver,
|
||||||
|
updateDir: config.ourWorkingDir + "/agh-update-" + newver,
|
||||||
|
backupDir: config.ourWorkingDir + "/agh-backup",
|
||||||
|
configName: config.ourWorkingDir + "/AdGuardHome.yaml",
|
||||||
|
updateConfigName: config.ourWorkingDir + "/agh-update-" + newver + "/AdGuardHome/AdGuardHome.yaml",
|
||||||
|
curBinName: config.ourWorkingDir + "/AdGuardHome",
|
||||||
|
bkpBinName: config.ourWorkingDir + "/agh-backup/AdGuardHome",
|
||||||
|
newBinName: config.ourWorkingDir + "/agh-update-" + newver + "/AdGuardHome/AdGuardHome",
|
||||||
|
}
|
||||||
|
|
||||||
|
if uu.pkgURL != u.pkgURL ||
|
||||||
|
uu.pkgName != u.pkgName ||
|
||||||
|
uu.newVer != u.newVer ||
|
||||||
|
uu.updateDir != u.updateDir ||
|
||||||
|
uu.backupDir != u.backupDir ||
|
||||||
|
uu.configName != u.configName ||
|
||||||
|
uu.updateConfigName != u.updateConfigName ||
|
||||||
|
uu.curBinName != u.curBinName ||
|
||||||
|
uu.bkpBinName != u.bkpBinName ||
|
||||||
|
uu.newBinName != u.newBinName {
|
||||||
|
t.Fatalf("getUpdateInfo: %v != %v", uu, u)
|
||||||
|
}
|
||||||
|
|
||||||
e := doUpdate(&u)
|
e := doUpdate(&u)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
t.Fatalf("FAILED: %s", e)
|
t.Fatalf("FAILED: %s", e)
|
||||||
|
Loading…
Reference in New Issue
Block a user