Partner flow: QR scanner component (html5-qrcode) with camera permission/not-found handling, 3-step spend flow (scan → amount entry with auto-filled max → success/error result). Admin dashboard: stats overview, grant points with debounced student search, paginated transactions table with type filters, paginated students table. Tests: comprehensive unit tests for points and auth packages — service (all paths including error branches, RS256 wrong-method), handler (all HTTP status codes via httptest), JWT round-trip, repository constructors. Auth coverage: 72.9%, points service coverage: 100%. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
893 B
Go
32 lines
893 B
Go
package points_test
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/cu-points/backend/internal/points"
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
// TestNewRepository_Constructor exercises the factory function without a real DB.
|
|
// Method calls on the returned value would panic (nil pool), so we only test creation.
|
|
func TestNewRepository_Constructor(t *testing.T) {
|
|
repo := points.NewRepository(nil)
|
|
if repo == nil {
|
|
t.Error("NewRepository(nil) returned nil")
|
|
}
|
|
}
|
|
|
|
// TestNewRedisCache_Constructor exercises the cache factory without a real Redis.
|
|
func TestNewRedisCache_Constructor(t *testing.T) {
|
|
// Use a client with an unreachable address; we only test that construction succeeds.
|
|
client := redis.NewClient(&redis.Options{
|
|
Addr: "localhost:0",
|
|
DialTimeout: time.Millisecond,
|
|
})
|
|
cache := points.NewRedisCache(client)
|
|
if cache == nil {
|
|
t.Error("NewRedisCache returned nil")
|
|
}
|
|
}
|