Add a test for the install.py script

This commit is contained in:
David Dworken
2022-06-04 22:27:04 -07:00
parent 72bd46d4e8
commit 00f6bed62c
2 changed files with 47 additions and 4 deletions

View File

@ -514,16 +514,24 @@ func copyFile(src, dst string) error {
return err
}
func Update() error {
// Download the binary
func GetDownloadData() (shared.UpdateInfo, error) {
respBody, err := ApiGet("/api/v1/download")
if err != nil {
return fmt.Errorf("failed to download update info: %v", err)
return shared.UpdateInfo{}, fmt.Errorf("failed to download update info: %v", err)
}
var downloadData shared.UpdateInfo
err = json.Unmarshal(respBody, &downloadData)
if err != nil {
return fmt.Errorf("failed to parse update info: %v", err)
return shared.UpdateInfo{}, fmt.Errorf("failed to parse update info: %v", err)
}
return downloadData, nil
}
func Update() error {
// Download the binary
downloadData, err := GetDownloadData()
if err != nil {
return err
}
if downloadData.Version == "v0."+Version {
fmt.Printf("Latest version (v0.%s) is already installed\n", Version)