Final verification: All tests pass and code builds successfully

Co-authored-by: tankerkiller125 <3457368+tankerkiller125@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-11 00:16:23 +00:00
parent 47f87cbe30
commit c92488e90a
2 changed files with 12 additions and 12 deletions

View File

@@ -107,7 +107,7 @@ func TestItemService_AddAttachment_InvalidStorage(t *testing.T) {
// Attempt to add attachment with invalid storage - should return an error // Attempt to add attachment with invalid storage - should return an error
_, err = svc.AttachmentAdd(tCtx, itm.ID, "testfile.txt", "attachment", false, reader) _, err = svc.AttachmentAdd(tCtx, itm.ID, "testfile.txt", "attachment", false, reader)
// This should return an error now (after the fix) // This should return an error now (after the fix)
assert.Error(t, err, "AttachmentAdd should return an error when storage is invalid") assert.Error(t, err, "AttachmentAdd should return an error when storage is invalid")
} }

View File

@@ -3,18 +3,18 @@ package repo
import ( import (
"testing" "testing"
"github.com/sysadminsmedia/homebox/backend/pkgs/textutils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/sysadminsmedia/homebox/backend/pkgs/textutils"
) )
func TestItemsRepository_AccentInsensitiveSearch(t *testing.T) { func TestItemsRepository_AccentInsensitiveSearch(t *testing.T) {
// Test cases for accent-insensitive search // Test cases for accent-insensitive search
testCases := []struct { testCases := []struct {
name string name string
itemName string itemName string
searchQuery string searchQuery string
shouldMatch bool shouldMatch bool
description string description string
}{ }{
{ {
name: "Spanish accented item, search without accents", name: "Spanish accented item, search without accents",
@@ -155,25 +155,25 @@ func TestItemsRepository_AccentInsensitiveSearch(t *testing.T) {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
// Test the normalization logic used in the repository // Test the normalization logic used in the repository
normalizedSearch := textutils.NormalizeSearchQuery(tc.searchQuery) normalizedSearch := textutils.NormalizeSearchQuery(tc.searchQuery)
// This simulates what happens in the repository // This simulates what happens in the repository
// The original search would find exact matches (case-insensitive) // The original search would find exact matches (case-insensitive)
// The normalized search would find accent-insensitive matches // The normalized search would find accent-insensitive matches
// Test that our normalization works as expected // Test that our normalization works as expected
if tc.shouldMatch { if tc.shouldMatch {
// If it should match, then either the original query should match // If it should match, then either the original query should match
// or the normalized query should match when applied to the stored data // or the normalized query should match when applied to the stored data
assert.NotEqual(t, "", normalizedSearch, "Normalized search should not be empty") assert.NotEqual(t, "", normalizedSearch, "Normalized search should not be empty")
// The key insight is that we're searching with both the original and normalized queries // The key insight is that we're searching with both the original and normalized queries
// So "electrónica" will be found when searching for "electronica" because: // So "electrónica" will be found when searching for "electronica" because:
// 1. Original search: "electronica" doesn't match "electrónica" // 1. Original search: "electronica" doesn't match "electrónica"
// 2. Normalized search: "electronica" matches the normalized version // 2. Normalized search: "electronica" matches the normalized version
t.Logf("✓ %s: Item '%s' should be found with search '%s' (normalized: '%s')", t.Logf("✓ %s: Item '%s' should be found with search '%s' (normalized: '%s')",
tc.description, tc.itemName, tc.searchQuery, normalizedSearch) tc.description, tc.itemName, tc.searchQuery, normalizedSearch)
} else { } else {
t.Logf("✗ %s: Item '%s' should NOT be found with search '%s' (normalized: '%s')", t.Logf("✗ %s: Item '%s' should NOT be found with search '%s' (normalized: '%s')",
tc.description, tc.itemName, tc.searchQuery, normalizedSearch) tc.description, tc.itemName, tc.searchQuery, normalizedSearch)
} }
}) })