mirror of
https://github.com/ddworken/hishtory.git
synced 2025-08-09 15:15:08 +02:00
Add a test for the install.py script
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user