2022-02-18 09:16:20 +01:00
|
|
|
package update
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDownloadLatestRelease(t *testing.T) {
|
|
|
|
|
2022-03-28 11:43:17 +02:00
|
|
|
// Reset the version to test the latest release
|
|
|
|
Version = "0.0.0"
|
2022-02-18 09:16:20 +01:00
|
|
|
|
|
|
|
// change "exe" to /tmp/test-katenary
|
|
|
|
exe = "/tmp/test-katenary"
|
2022-02-20 15:23:55 +01:00
|
|
|
defer os.Remove(exe)
|
2022-02-18 09:16:20 +01:00
|
|
|
|
|
|
|
// Now call the CheckLatestVersion function
|
|
|
|
version, assets, err := CheckLatestVersion()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Error: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("Version found", version)
|
|
|
|
|
|
|
|
// Touch exe binary
|
|
|
|
f, _ := os.OpenFile(exe, os.O_RDONLY|os.O_CREATE, 0755)
|
|
|
|
f.Write(nil)
|
|
|
|
f.Close()
|
|
|
|
|
|
|
|
err = DownloadLatestVersion(assets)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Error: %s", err)
|
|
|
|
}
|
|
|
|
}
|