actually commit my changes this time...

This commit is contained in:
Ashley Mensah
2025-11-05 17:11:23 +01:00
parent 030ddae51e
commit 8aa1b23a22
6 changed files with 28 additions and 1 deletions

View File

@@ -61,6 +61,9 @@ type UpdateManager struct {
// updateMutex protect update and expectedVersion fields
updateMutex sync.Mutex
// updateFunc is used for testing to mock the triggerUpdate behavior
updateFunc func(ctx context.Context, targetVersion string) error
}
func NewUpdateManager(statusRecorder *peer.Status, stateManager *statemanager.Manager) *UpdateManager {
@@ -79,7 +82,6 @@ func NewUpdateManager(statusRecorder *peer.Status, stateManager *statemanager.Ma
// CheckUpdateSuccess checks if the update was successful. It works without to start the update manager.
func (u *UpdateManager) CheckUpdateSuccess(ctx context.Context) {
u.updateStateManager(ctx)
return
}
func (u *UpdateManager) Start(ctx context.Context) {

View File

@@ -18,6 +18,11 @@ const (
)
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
// Use test function if set (for testing only)
if u.updateFunc != nil {
return u.updateFunc(ctx, targetVersion)
}
cmd := exec.CommandContext(ctx, "pkgutil", "--pkg-info", "io.netbird.client")
outBytes, err := cmd.Output()
if err != nil && cmd.ProcessState.ExitCode() == 1 {

View File

@@ -5,6 +5,11 @@ package updatemanager
import "context"
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
// Use test function if set (for testing purposes)
if u.updateFunc != nil {
return u.updateFunc(ctx, targetVersion)
}
// TODO: Implement
return nil
}

View File

@@ -5,6 +5,11 @@ package updatemanager
import "context"
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
// Use test function if set (for testing purposes)
if u.updateFunc != nil {
return u.updateFunc(ctx, targetVersion)
}
// TODO: Implement
return nil
}

View File

@@ -5,6 +5,11 @@ package updatemanager
import "context"
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
// Use test function if set (for testing purposes)
if u.updateFunc != nil {
return u.updateFunc(ctx, targetVersion)
}
// TODO: Implement
return nil
}

View File

@@ -26,6 +26,11 @@ const (
type installerType string
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
// Use test function if set (for testing purposes)
if u.updateFunc != nil {
return u.updateFunc(ctx, targetVersion)
}
method := installation()
return install(ctx, method, targetVersion)
}