mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 15:44:21 +00:00
Setup test logging
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
func TestDefaultConfig(t *testing.T) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"novamd/internal/auth"
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
func TestNewJWTService(t *testing.T) {
|
||||
|
||||
@@ -141,7 +141,6 @@ func (m *Middleware) RequireWorkspaceAccess(next http.Handler) http.Handler {
|
||||
"handler", "RequireWorkspaceAccess",
|
||||
"clientIP", r.RemoteAddr,
|
||||
"userId", ctx.UserID,
|
||||
"workspaceId", ctx.Workspace.ID,
|
||||
)
|
||||
|
||||
// If no workspace in context, allow the request
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"novamd/internal/auth"
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
// Mock SessionManager
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"novamd/internal/auth"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
// Mock SessionStore
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"novamd/internal/context"
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
func TestGetRequestContext(t *testing.T) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"novamd/internal/context"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
// MockDB implements the minimal database interface needed for testing
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
|
||||
"novamd/internal/db"
|
||||
|
||||
_ "novamd/internal/testenv"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
func TestUserOperations(t *testing.T) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package db_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"novamd/internal/db"
|
||||
"novamd/internal/models"
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
func TestWorkspaceOperations(t *testing.T) {
|
||||
@@ -385,8 +385,8 @@ func TestWorkspaceOperations(t *testing.T) {
|
||||
|
||||
// Verify workspace is gone
|
||||
_, err = database.GetWorkspaceByID(workspace.ID)
|
||||
if err != sql.ErrNoRows {
|
||||
t.Errorf("expected sql.ErrNoRows, got %v", err)
|
||||
if !strings.Contains(err.Error(), "workspace not found") {
|
||||
t.Errorf("expected workspace not found, got %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -199,13 +199,8 @@ func (h *Handler) Logout(authManager auth.SessionManager, cookieService auth.Coo
|
||||
// @Router /auth/refresh [post]
|
||||
func (h *Handler) RefreshToken(authManager auth.SessionManager, cookieService auth.CookieManager) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, ok := context.GetRequestContext(w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
log := getAuthLogger().With(
|
||||
"handler", "RefreshToken",
|
||||
"userID", ctx.UserID,
|
||||
"clientIP", r.RemoteAddr,
|
||||
)
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ import (
|
||||
"novamd/internal/models"
|
||||
"novamd/internal/secrets"
|
||||
"novamd/internal/storage"
|
||||
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
// testHarness encapsulates all the dependencies needed for testing
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"novamd/internal/secrets"
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
func TestValidateKey(t *testing.T) {
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"novamd/internal/storage"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
// TestFileNode ensures FileNode structs are created correctly
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
type mockDirEntry struct {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"novamd/internal/git"
|
||||
"novamd/internal/storage"
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
// MockGitClient implements git.Client interface for testing
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"novamd/internal/storage"
|
||||
_ "novamd/internal/testenv"
|
||||
)
|
||||
|
||||
func TestValidatePath(t *testing.T) {
|
||||
|
||||
9
server/internal/testenv/testenv.go
Normal file
9
server/internal/testenv/testenv.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Package testenv provides a setup for testing the application.
|
||||
package testenv
|
||||
|
||||
import "novamd/internal/logging"
|
||||
|
||||
func init() {
|
||||
// Initialize the logger
|
||||
logging.Setup(logging.ERROR)
|
||||
}
|
||||
Reference in New Issue
Block a user