github.com/fastly/cli@v1.7.2-0.20240304164155-9d0f1d77c3bf/pkg/mock/versioner.go (about)

     1  package mock
     2  
     3  import "fmt"
     4  
     5  // AssetVersioner mocks the github.AssetVersioner interface.
     6  type AssetVersioner struct {
     7  	AssetVersion    string
     8  	BinaryFilename  string
     9  	DownloadOK      bool
    10  	DownloadedFile  string
    11  	InstallFilePath string
    12  }
    13  
    14  // BinaryName implements github.Versioner interface.
    15  func (av AssetVersioner) BinaryName() string {
    16  	return av.BinaryFilename
    17  }
    18  
    19  // DownloadLatest implements github.Versioner interface.
    20  func (av AssetVersioner) DownloadLatest() (string, error) {
    21  	if av.DownloadOK {
    22  		return av.DownloadedFile, nil
    23  	}
    24  	return "", fmt.Errorf("not implemented")
    25  }
    26  
    27  // DownloadVersion implements github.Versioner interface.
    28  func (av AssetVersioner) DownloadVersion(_ string) (string, error) {
    29  	return "", nil
    30  }
    31  
    32  // Download implements github.Versioner interface.
    33  func (av AssetVersioner) Download(_ string) (string, error) {
    34  	return "", nil
    35  }
    36  
    37  // URL implements github.Versioner interface.
    38  func (av AssetVersioner) URL() (string, error) {
    39  	return "", nil
    40  }
    41  
    42  // LatestVersion implements github.Versioner interface.
    43  func (av AssetVersioner) LatestVersion() (string, error) {
    44  	return av.AssetVersion, nil
    45  }
    46  
    47  // RequestedVersion implements github.Versioner interface.
    48  func (av AssetVersioner) RequestedVersion() (version string) {
    49  	return ""
    50  }
    51  
    52  // SetRequestedVersion implements github.Versioner interface.
    53  func (av AssetVersioner) SetRequestedVersion(_ string) {
    54  	// no-op
    55  }
    56  
    57  // InstallPath returns the location of where the binary should be installed.
    58  func (av AssetVersioner) InstallPath() string {
    59  	return av.InstallFilePath
    60  }