Add comprehensive kanban board tests and fix test suite
- Add 13 tests for task kanban categorization and button types - Fix i18n initialization in test setup (was causing nil pointer panics) - Add TaskCompletionImage to test DB auto-migrate - Update ListTasks tests to expect kanban board response instead of array 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -13,11 +14,19 @@ import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
|
||||
"github.com/treytartt/casera-api/internal/i18n"
|
||||
"github.com/treytartt/casera-api/internal/models"
|
||||
)
|
||||
|
||||
var i18nOnce sync.Once
|
||||
|
||||
// SetupTestDB creates an in-memory SQLite database for testing
|
||||
func SetupTestDB(t *testing.T) *gorm.DB {
|
||||
// Initialize i18n once for all tests
|
||||
i18nOnce.Do(func() {
|
||||
i18n.Init()
|
||||
})
|
||||
|
||||
db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{
|
||||
Logger: logger.Default.LogMode(logger.Silent),
|
||||
})
|
||||
@@ -40,6 +49,7 @@ func SetupTestDB(t *testing.T) *gorm.DB {
|
||||
&models.TaskStatus{},
|
||||
&models.TaskFrequency{},
|
||||
&models.TaskCompletion{},
|
||||
&models.TaskCompletionImage{},
|
||||
&models.Contractor{},
|
||||
&models.ContractorSpecialty{},
|
||||
&models.Document{},
|
||||
|
||||
Reference in New Issue
Block a user