042a1d4773
* introduced central package registry by package init function * dynamic registration of routes, model, migrations and initializers. * setting a docker compose project name to prevent shutdown of other containers with the same (composer)name * ai documentation * app template * Create tests for ALL API entpoints in ALL packages Based on current data. Ensure that all API endpoints used in frontend are tested. These tests are crucial for the next refactoring tasks. * adopting agent instructions for a more consistent coding style * added desired module layout and debugging information * Fix All Failing tests All failing tests are fixed now that makes the refactoring more easy since all tests must pass * restored routes for maintenance * added common translations * added new tests for API Endpoint * Merge branch 'separate_business_logic' * added lern and skill improvement cost editing * Set Docker image tag when building to prevent rebuild when nothing has changed * add and remove PP for Weaponskill fixed * add and remove PP for same named skills fixed * add new task
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package character
|
|
|
|
import (
|
|
"bamort/database"
|
|
"bamort/bmrt/models"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDebugPracticePoints(t *testing.T) {
|
|
// Setup test database
|
|
database.SetupTestDB()
|
|
defer database.ResetTestDB()
|
|
|
|
// Migrate the schema
|
|
err := models.MigrateStructure()
|
|
assert.NoError(t, err)
|
|
|
|
// Create a test character manually using GORM
|
|
character := &models.Char{
|
|
BamortBase: models.BamortBase{
|
|
Name: "Test Character",
|
|
},
|
|
Rasse: "Human",
|
|
Typ: "Hx",
|
|
}
|
|
err = database.DB.Create(character).Error
|
|
assert.NoError(t, err)
|
|
|
|
// Setup Gin router
|
|
gin.SetMode(gin.TestMode)
|
|
router := gin.New()
|
|
|
|
// Register routes
|
|
api := router.Group("/api")
|
|
RegisterRoutes(api)
|
|
|
|
// Test the endpoint
|
|
req := httptest.NewRequest(http.MethodGet, "/api/characters/"+strconv.Itoa(int(character.ID))+"/practice-points", nil)
|
|
w := httptest.NewRecorder()
|
|
router.ServeHTTP(w, req)
|
|
|
|
t.Logf("Status: %d", w.Code)
|
|
t.Logf("Body: %s", w.Body.String())
|
|
|
|
// Check if the character exists in database
|
|
var testChar models.Char
|
|
err = database.DB.First(&testChar, character.ID).Error
|
|
t.Logf("Character exists in DB: %v, ID: %d, Error: %v", err == nil, character.ID, err)
|
|
}
|