2019-06-06 09:20:26 +00:00
|
|
|
// +build ignore
|
|
|
|
|
2019-06-10 08:33:19 +00:00
|
|
|
package home
|
2019-04-25 11:57:03 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2019-06-06 09:20:26 +00:00
|
|
|
func TestDoUpdate(t *testing.T) {
|
2019-04-25 11:57:03 +00:00
|
|
|
config.DNS.Port = 0
|
2019-06-05 14:54:25 +00:00
|
|
|
config.ourWorkingDir = "."
|
2019-04-25 11:57:03 +00:00
|
|
|
u := updateInfo{
|
|
|
|
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",
|
|
|
|
newVer: "v0.95",
|
2019-06-05 15:00:17 +00:00
|
|
|
updateDir: "./agh-update-v0.95",
|
|
|
|
backupDir: "./agh-backup-v0.94",
|
2019-04-25 11:57:03 +00:00
|
|
|
configName: "./AdGuardHome.yaml",
|
2019-06-05 15:00:17 +00:00
|
|
|
updateConfigName: "./agh-update-v0.95/AdGuardHome/AdGuardHome.yaml",
|
2019-04-25 11:57:03 +00:00
|
|
|
curBinName: "./AdGuardHome",
|
2019-06-05 15:00:17 +00:00
|
|
|
bkpBinName: "./agh-backup-v0.94/AdGuardHome",
|
|
|
|
newBinName: "./agh-update-v0.95/AdGuardHome/AdGuardHome",
|
2019-04-25 11:57:03 +00:00
|
|
|
}
|
|
|
|
e := doUpdate(&u)
|
|
|
|
if e != nil {
|
|
|
|
t.Fatalf("FAILED: %s", e)
|
|
|
|
}
|
|
|
|
os.RemoveAll(u.backupDir)
|
|
|
|
}
|
|
|
|
|
2019-06-06 09:20:26 +00:00
|
|
|
func TestTargzFileUnpack(t *testing.T) {
|
2019-06-05 12:27:32 +00:00
|
|
|
fn := "./dist/AdGuardHome_v0.95_linux_amd64.tar.gz"
|
|
|
|
outdir := "./test-unpack"
|
|
|
|
_ = os.Mkdir(outdir, 0755)
|
|
|
|
files, e := targzFileUnpack(fn, outdir)
|
|
|
|
if e != nil {
|
|
|
|
t.Fatalf("FAILED: %s", e)
|
|
|
|
}
|
|
|
|
t.Logf("%v", files)
|
|
|
|
os.RemoveAll(outdir)
|
|
|
|
}
|
|
|
|
|
2019-06-06 09:20:26 +00:00
|
|
|
func TestZipFileUnpack(t *testing.T) {
|
2019-04-25 11:57:03 +00:00
|
|
|
fn := "./dist/AdGuardHome_v0.95_Windows_amd64.zip"
|
|
|
|
outdir := "./test-unpack"
|
|
|
|
_ = os.Mkdir(outdir, 0755)
|
2019-06-05 12:33:09 +00:00
|
|
|
files, e := zipFileUnpack(fn, outdir)
|
2019-04-25 11:57:03 +00:00
|
|
|
if e != nil {
|
|
|
|
t.Fatalf("FAILED: %s", e)
|
|
|
|
}
|
2019-06-05 12:33:09 +00:00
|
|
|
t.Logf("%v", files)
|
2019-04-25 11:57:03 +00:00
|
|
|
os.RemoveAll(outdir)
|
|
|
|
}
|