From 37067ef93391e4e8da6b5b71f7d2be9ad1622883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Nordstr=C3=B6m?= Date: Mon, 23 Sep 2024 20:21:38 +0200 Subject: [PATCH] rename DeleteKey to Delete --- libs/auth/cache/cache.go | 2 +- libs/auth/cache/file.go | 2 +- libs/auth/cache/file_test.go | 4 ++-- libs/auth/cache/in_memory.go | 4 ++-- libs/auth/cache/in_memory_test.go | 4 ++-- libs/auth/oauth.go | 2 +- libs/auth/oauth_test.go | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/auth/cache/cache.go b/libs/auth/cache/cache.go index 7ca9e8b6..2c88d093 100644 --- a/libs/auth/cache/cache.go +++ b/libs/auth/cache/cache.go @@ -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 diff --git a/libs/auth/cache/file.go b/libs/auth/cache/file.go index 9e99070e..4a7c3781 100644 --- a/libs/auth/cache/file.go +++ b/libs/auth/cache/file.go @@ -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 diff --git a/libs/auth/cache/file_test.go b/libs/auth/cache/file_test.go index fb7375c2..bd3f84ac 100644 --- a/libs/auth/cache/file_test.go +++ b/libs/auth/cache/file_test.go @@ -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") diff --git a/libs/auth/cache/in_memory.go b/libs/auth/cache/in_memory.go index 6daaf868..756002e0 100644 --- a/libs/auth/cache/in_memory.go +++ b/libs/auth/cache/in_memory.go @@ -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 diff --git a/libs/auth/cache/in_memory_test.go b/libs/auth/cache/in_memory_test.go index 3714ed79..73995231 100644 --- a/libs/auth/cache/in_memory_test.go +++ b/libs/auth/cache/in_memory_test.go @@ -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") diff --git a/libs/auth/oauth.go b/libs/auth/oauth.go index 46f2af11..ec615fe7 100644 --- a/libs/auth/oauth.go +++ b/libs/auth/oauth.go @@ -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 { diff --git a/libs/auth/oauth_test.go b/libs/auth/oauth_test.go index e5e36032..fd245c67 100644 --- a/libs/auth/oauth_test.go +++ b/libs/auth/oauth_test.go @@ -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") }