Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
Add an interface to the updater for better testing
Browse files Browse the repository at this point in the history
  • Loading branch information
aabri-ankorstore committed Feb 23, 2023
1 parent a885d4c commit 16bd2bf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion selfupdate/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@ package selfupdate
import (
"context"
"fmt"
"io"
"net/http"
"os"
"regexp"

"github.com/blang/semver"
"github.com/google/go-github/v30/github"
gitconfig "github.com/tcnksm/go-gitconfig"
"github.com/tcnksm/go-gitconfig"
"golang.org/x/oauth2"
)

type UpdaterIn interface {
DetectLatest(slug string) (release *Release, found bool, err error)
DetectVersion(slug string, version string) (release *Release, found bool, err error)
downloadDirectlyFromURL(assetURL string) (io.ReadCloser, error)
UpdateTo(rel *Release, cmdPath string) error
UpdateCommand(cmdPath string, current semver.Version, slug string) (*Release, error)
UpdateSelf(current semver.Version, slug string) (*Release, error)
}

// Updater is responsible for managing the context of self-update.
// It contains GitHub client and its context.
type Updater struct {
Expand Down

0 comments on commit 16bd2bf

Please sign in to comment.