Improved testing
This commit is contained in:
+43
-3
@@ -14,9 +14,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
downloadURL = "https://github.com/srevinsaju/Firefox-Appimage/releases/download/firefox-v84.0.r20201221152838/firefox-84.0.r20201221152838-x86_64.AppImage"
|
appImageURL = "https://github.com/srevinsaju/Firefox-Appimage/releases/download/firefox-v84.0.r20201221152838/firefox-84.0.r20201221152838-x86_64.AppImage"
|
||||||
appImageName = "firefox-84.0.r20201221152838-x86_64.AppImage"
|
appImageName = "firefox-84.0.r20201221152838-x86_64.AppImage"
|
||||||
squashfsName = "balenaEtcher-1.5.113-x64.AppImage.sfs"
|
squashfsURL = "https://darkstorm.tech/LinuxPATest.sfs"
|
||||||
|
squashfsName = "LinuxPATest.sfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSquashfs(t *testing.T) {
|
func TestSquashfs(t *testing.T) {
|
||||||
@@ -25,6 +26,13 @@ func TestSquashfs(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
squashFil, err := os.Open(wd + "/testing/" + squashfsName)
|
squashFil, err := os.Open(wd + "/testing/" + squashfsName)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
err = downloadTestSquash(wd + "/testing")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
squashFil, err = os.Open(wd + "/testing/" + squashfsName)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -32,6 +40,12 @@ func TestSquashfs(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
op := DefaultOptions()
|
||||||
|
op.Verbose = true
|
||||||
|
err = rdr.ExtractWithOptions(wd+"/testing/"+squashfsName+".d", op)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
fmt.Println("stuff", rdr.super.CompressionType)
|
fmt.Println("stuff", rdr.super.CompressionType)
|
||||||
// fil := rdr.GetFileAtPath("*.desktop")
|
// fil := rdr.GetFileAtPath("*.desktop")
|
||||||
// if fil == nil {
|
// if fil == nil {
|
||||||
@@ -171,7 +185,7 @@ func downloadTestAppImage(dir string) error {
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
resp, err := check.Get(downloadURL)
|
resp, err := check.Get(appImageURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -183,6 +197,32 @@ func downloadTestAppImage(dir string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func downloadTestSquash(dir string) error {
|
||||||
|
//seems to time out on slow connections. Might fix that at some point... or not. It's just a test...
|
||||||
|
os.Mkdir(dir, os.ModePerm)
|
||||||
|
sfs, err := os.Create(dir + "/" + squashfsName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer sfs.Close()
|
||||||
|
check := http.Client{
|
||||||
|
CheckRedirect: func(r *http.Request, _ []*http.Request) error {
|
||||||
|
r.URL.Opaque = r.URL.Path
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
resp, err := check.Get(squashfsURL)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
_, err = io.Copy(sfs, resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreateSquashFromAppImage(t *testing.T) {
|
func TestCreateSquashFromAppImage(t *testing.T) {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user