Bring extension update check in line with gh check
This commit is a bit of refactoring to bring the extension update checking logic up to par with what is done with `gh` including creation of state file per extension and listening to env vars for disabling version checking. This work is not complete as it does not address necessary test changes.
This commit is contained in:
parent
9decf1b526
commit
0d3f7cae4e
6 changed files with 125 additions and 46 deletions
|
|
@ -20,6 +20,9 @@ var _ Extension = &ExtensionMock{}
|
|||
// CurrentVersionFunc: func() string {
|
||||
// panic("mock out the CurrentVersion method")
|
||||
// },
|
||||
// FullNameFunc: func() string {
|
||||
// panic("mock out the FullName method")
|
||||
// },
|
||||
// IsBinaryFunc: func() bool {
|
||||
// panic("mock out the IsBinary method")
|
||||
// },
|
||||
|
|
@ -57,6 +60,9 @@ type ExtensionMock struct {
|
|||
// CurrentVersionFunc mocks the CurrentVersion method.
|
||||
CurrentVersionFunc func() string
|
||||
|
||||
// FullNameFunc mocks the FullName method.
|
||||
FullNameFunc func() string
|
||||
|
||||
// IsBinaryFunc mocks the IsBinary method.
|
||||
IsBinaryFunc func() bool
|
||||
|
||||
|
|
@ -89,6 +95,9 @@ type ExtensionMock struct {
|
|||
// CurrentVersion holds details about calls to the CurrentVersion method.
|
||||
CurrentVersion []struct {
|
||||
}
|
||||
// FullName holds details about calls to the FullName method.
|
||||
FullName []struct {
|
||||
}
|
||||
// IsBinary holds details about calls to the IsBinary method.
|
||||
IsBinary []struct {
|
||||
}
|
||||
|
|
@ -118,6 +127,7 @@ type ExtensionMock struct {
|
|||
}
|
||||
}
|
||||
lockCurrentVersion sync.RWMutex
|
||||
lockFullName sync.RWMutex
|
||||
lockIsBinary sync.RWMutex
|
||||
lockIsLocal sync.RWMutex
|
||||
lockIsPinned sync.RWMutex
|
||||
|
|
@ -156,6 +166,33 @@ func (mock *ExtensionMock) CurrentVersionCalls() []struct {
|
|||
return calls
|
||||
}
|
||||
|
||||
// FullName calls FullNameFunc.
|
||||
func (mock *ExtensionMock) FullName() string {
|
||||
if mock.FullNameFunc == nil {
|
||||
panic("ExtensionMock.FullNameFunc: method is nil but Extension.FullName was just called")
|
||||
}
|
||||
callInfo := struct {
|
||||
}{}
|
||||
mock.lockFullName.Lock()
|
||||
mock.calls.FullName = append(mock.calls.FullName, callInfo)
|
||||
mock.lockFullName.Unlock()
|
||||
return mock.FullNameFunc()
|
||||
}
|
||||
|
||||
// FullNameCalls gets all the calls that were made to FullName.
|
||||
// Check the length with:
|
||||
//
|
||||
// len(mockedExtension.FullNameCalls())
|
||||
func (mock *ExtensionMock) FullNameCalls() []struct {
|
||||
} {
|
||||
var calls []struct {
|
||||
}
|
||||
mock.lockFullName.RLock()
|
||||
calls = mock.calls.FullName
|
||||
mock.lockFullName.RUnlock()
|
||||
return calls
|
||||
}
|
||||
|
||||
// IsBinary calls IsBinaryFunc.
|
||||
func (mock *ExtensionMock) IsBinary() bool {
|
||||
if mock.IsBinaryFunc == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue