mirror of
https://github.com/aykhans/slash-e.git
synced 2026-09-23 14:26:49 +00:00
chore: fix linter errors
This commit is contained in:
@@ -29,7 +29,7 @@ func GetImage(urlStr string) (*Image, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(mediatype, "image/") {
|
if !strings.HasPrefix(mediatype, "image/") {
|
||||||
return nil, errors.New("Wrong image mediatype")
|
return nil, errors.New("wrong image mediatype")
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyBytes, err := io.ReadAll(response.Body)
|
bodyBytes, err := io.ReadAll(response.Body)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func GetSchemaVersion(version string) string {
|
|||||||
return minorVersion + ".0"
|
return minorVersion + ".0"
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsVersionGreaterThanOrEqualTo returns true if version is greater than or equal to target.
|
// IsVersionGreaterOrEqualThan returns true if version is greater than or equal to target.
|
||||||
func IsVersionGreaterOrEqualThan(version, target string) bool {
|
func IsVersionGreaterOrEqualThan(version, target string) bool {
|
||||||
return semver.Compare(fmt.Sprintf("v%s", version), fmt.Sprintf("v%s", target)) > -1
|
return semver.Compare(fmt.Sprintf("v%s", version), fmt.Sprintf("v%s", target)) > -1
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -62,7 +62,9 @@ func (s *Store) ListShortcuts(ctx context.Context, find *FindShortcut) ([]*store
|
|||||||
func (s *Store) GetShortcut(ctx context.Context, find *FindShortcut) (*storepb.Shortcut, error) {
|
func (s *Store) GetShortcut(ctx context.Context, find *FindShortcut) (*storepb.Shortcut, error) {
|
||||||
if find.ID != nil {
|
if find.ID != nil {
|
||||||
if cache, ok := s.shortcutCache.Load(*find.ID); ok {
|
if cache, ok := s.shortcutCache.Load(*find.ID); ok {
|
||||||
return cache.(*storepb.Shortcut), nil
|
if shortcut, ok := cache.(*storepb.Shortcut); ok {
|
||||||
|
return shortcut, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -85,7 +85,9 @@ func (s *Store) ListUsers(ctx context.Context, find *FindUser) ([]*User, error)
|
|||||||
func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error) {
|
func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error) {
|
||||||
if find.ID != nil {
|
if find.ID != nil {
|
||||||
if cache, ok := s.userCache.Load(*find.ID); ok {
|
if cache, ok := s.userCache.Load(*find.ID); ok {
|
||||||
return cache.(*User), nil
|
if user, ok := cache.(*User); ok {
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]
|
|||||||
func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error) {
|
func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error) {
|
||||||
if find.UserID != nil && find.Key != storepb.UserSettingKey_USER_SETTING_KEY_UNSPECIFIED {
|
if find.UserID != nil && find.Key != storepb.UserSettingKey_USER_SETTING_KEY_UNSPECIFIED {
|
||||||
if cache, ok := s.userSettingCache.Load(getUserSettingCacheKey(*find.UserID, find.Key.String())); ok {
|
if cache, ok := s.userSettingCache.Load(getUserSettingCacheKey(*find.UserID, find.Key.String())); ok {
|
||||||
return cache.(*storepb.UserSetting), nil
|
if userSetting, ok := cache.(*storepb.UserSetting); ok {
|
||||||
|
return userSetting, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ func (s *Store) ListWorkspaceSettings(ctx context.Context, find *FindWorkspaceSe
|
|||||||
func (s *Store) GetWorkspaceSetting(ctx context.Context, find *FindWorkspaceSetting) (*storepb.WorkspaceSetting, error) {
|
func (s *Store) GetWorkspaceSetting(ctx context.Context, find *FindWorkspaceSetting) (*storepb.WorkspaceSetting, error) {
|
||||||
if find.Key != storepb.WorkspaceSettingKey_WORKSPACE_SETTING_KEY_UNSPECIFIED {
|
if find.Key != storepb.WorkspaceSettingKey_WORKSPACE_SETTING_KEY_UNSPECIFIED {
|
||||||
if cache, ok := s.workspaceSettingCache.Load(find.Key); ok {
|
if cache, ok := s.workspaceSettingCache.Load(find.Key); ok {
|
||||||
return cache.(*storepb.WorkspaceSetting), nil
|
if workspaceSetting, ok := cache.(*storepb.WorkspaceSetting); ok {
|
||||||
|
return workspaceSetting, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,15 +31,15 @@ func TestCollectionStore(t *testing.T) {
|
|||||||
require.Equal(t, 1, len(collections))
|
require.Equal(t, 1, len(collections))
|
||||||
require.Equal(t, collection, collections[0])
|
require.Equal(t, collection, collections[0])
|
||||||
newTitle := "My new collection"
|
newTitle := "My new collection"
|
||||||
newShortcutIds := []int32{101, 103}
|
newShortcutIDs := []int32{101, 103}
|
||||||
updatedCollection, err := ts.UpdateCollection(ctx, &store.UpdateCollection{
|
updatedCollection, err := ts.UpdateCollection(ctx, &store.UpdateCollection{
|
||||||
ID: collection.Id,
|
ID: collection.Id,
|
||||||
Title: &newTitle,
|
Title: &newTitle,
|
||||||
ShortcutIDs: newShortcutIds,
|
ShortcutIDs: newShortcutIDs,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, newTitle, updatedCollection.Title)
|
require.Equal(t, newTitle, updatedCollection.Title)
|
||||||
require.Equal(t, newShortcutIds, updatedCollection.ShortcutIds)
|
require.Equal(t, newShortcutIDs, updatedCollection.ShortcutIds)
|
||||||
err = ts.DeleteCollection(ctx, &store.DeleteCollection{
|
err = ts.DeleteCollection(ctx, &store.DeleteCollection{
|
||||||
ID: collection.Id,
|
ID: collection.Id,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user