golang.zx2c4.com/wireguard/windows@v0.5.4-0.20230123132234-dcc0eb72a04b/updater/updater_test.go (about) 1 /* SPDX-License-Identifier: MIT 2 * 3 * Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved. 4 */ 5 6 package updater 7 8 import ( 9 "testing" 10 ) 11 12 func TestUpdate(t *testing.T) { 13 update, err := CheckForUpdate() 14 if err != nil { 15 t.Error(err) 16 return 17 } 18 if update == nil { 19 t.Error("No update available") 20 return 21 } 22 t.Log("Found update") 23 progress := DownloadVerifyAndExecute(0) 24 for { 25 dp := <-progress 26 if dp.Error != nil { 27 t.Error(dp.Error) 28 return 29 } 30 if len(dp.Activity) > 0 { 31 t.Log(dp.Activity) 32 } 33 if dp.BytesTotal > 0 { 34 t.Logf("Downloaded %d of %d", dp.BytesDownloaded, dp.BytesTotal) 35 } 36 if dp.Complete { 37 t.Log("Complete!") 38 break 39 } 40 } 41 }