mirror of https://github.com/databricks/cli.git
rename DeleteKey to Delete
This commit is contained in:
parent
171c3fdd75
commit
37067ef933
|
@ -9,7 +9,7 @@ import (
|
|||
type TokenCache interface {
|
||||
Store(key string, t *oauth2.Token) error
|
||||
Lookup(key string) (*oauth2.Token, error)
|
||||
DeleteKey(key string) error
|
||||
Delete(key string) error
|
||||
}
|
||||
|
||||
var tokenCache int
|
||||
|
|
|
@ -73,7 +73,7 @@ func (c *FileTokenCache) Lookup(key string) (*oauth2.Token, error) {
|
|||
return t, nil
|
||||
}
|
||||
|
||||
func (c *FileTokenCache) DeleteKey(key string) error {
|
||||
func (c *FileTokenCache) Delete(key string) error {
|
||||
err := c.load()
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return ErrNotConfigured
|
||||
|
|
|
@ -118,7 +118,7 @@ func TestStoreAndDeleteKey(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
l := &FileTokenCache{}
|
||||
err = l.DeleteKey("x")
|
||||
err = l.Delete("x")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 1, len(l.Tokens))
|
||||
|
||||
|
@ -134,7 +134,7 @@ func TestDeleteKeyNotExist(t *testing.T) {
|
|||
c := &FileTokenCache{
|
||||
Tokens: map[string]*oauth2.Token{},
|
||||
}
|
||||
err := c.DeleteKey("x")
|
||||
err := c.Delete("x")
|
||||
assert.Equal(t, ErrNotConfigured, err)
|
||||
|
||||
_, err = c.Lookup("x")
|
||||
|
|
|
@ -23,8 +23,8 @@ func (i *InMemoryTokenCache) Store(key string, t *oauth2.Token) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DeleteKey implements TokenCache.
|
||||
func (i *InMemoryTokenCache) DeleteKey(key string) error {
|
||||
// Delete implements TokenCache.
|
||||
func (i *InMemoryTokenCache) Delete(key string) error {
|
||||
_, ok := i.Tokens[key]
|
||||
if !ok {
|
||||
return ErrNotConfigured
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestInMemoryDeleteKey(t *testing.T) {
|
|||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
err = c.DeleteKey("x")
|
||||
err = c.Delete("x")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 1, len(c.Tokens))
|
||||
|
||||
|
@ -74,7 +74,7 @@ func TestInMemoryDeleteKeyNotExist(t *testing.T) {
|
|||
c := &InMemoryTokenCache{
|
||||
Tokens: map[string]*oauth2.Token{},
|
||||
}
|
||||
err := c.DeleteKey("x")
|
||||
err := c.Delete("x")
|
||||
assert.Equal(t, ErrNotConfigured, err)
|
||||
|
||||
_, err = c.Lookup("x")
|
||||
|
|
|
@ -152,7 +152,7 @@ func (a *PersistentAuth) ClearToken(ctx context.Context) error {
|
|||
}
|
||||
// lookup token identified by host (and possibly the account id)
|
||||
key := a.key()
|
||||
return a.cache.DeleteKey(key)
|
||||
return a.cache.Delete(key)
|
||||
}
|
||||
|
||||
func (a *PersistentAuth) init(ctx context.Context) error {
|
||||
|
|
|
@ -72,7 +72,7 @@ func (m *tokenCacheMock) Lookup(key string) (*oauth2.Token, error) {
|
|||
return m.lookup(key)
|
||||
}
|
||||
|
||||
func (m *tokenCacheMock) DeleteKey(key string) error {
|
||||
func (m *tokenCacheMock) Delete(key string) error {
|
||||
if m.deleteKey == nil {
|
||||
panic("no deleteKey mock")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue