Files
CollabTable/CollabTableServer/sync_test.go
T
Gabriel20xx cac2faae2e
Docker / Docker Build & Push (push) Successful in 10m21s
Lint / Lint (push) Failing after 14s
Tests / Go backend (push) Successful in 21s
Tests / Dashboard checks (push) Successful in 21s
feat: initialize CollabTableServer with models, sync, and notification handling
- Add go.mod and go.sum for dependency management
- Implement models for List, Field, Item, ItemValue, SyncRequest, SyncResponse, and NotificationEvent
- Create notification handling functions including enqueueNotification and ignoreNotificationError
- Implement sync functionality to handle data synchronization between client and server
- Add web data handling and notification polling endpoints
- Include tests for timestamp normalization and sync logic
- Embed web assets for serving the frontend application
2026-08-03 18:07:40 +02:00

28 lines
922 B
Go

package main
import "testing"
func TestNormalizeTimestampConvertsSeconds(t *testing.T) {
const now = int64(1_700_000_000_000)
if got := normalizeTimestamp(1_700_000_000, 0, now); got != 1_700_000_000_000 {
t.Fatalf("normalizeTimestamp() = %d, want %d", got, 1_700_000_000_000)
}
}
func TestNormalizeTimestampClampsFutureValues(t *testing.T) {
t.Setenv("SYNC_MAX_FUTURE_SKEW_MS", "0")
const now = int64(1_700_000_000_000)
if got := normalizeTimestamp(now+1000, 0, now); got != now {
t.Fatalf("normalizeTimestamp() = %d, want %d", got, now)
}
}
func TestNormalizeEntityTimestampsKeepsUpdatedAfterCreated(t *testing.T) {
t.Setenv("SYNC_MAX_FUTURE_SKEW_MS", "0")
const now = int64(1_700_000_000_000)
created, updated := normalizeEntityTimestamps(now-100, now-200, now)
if created != now-100 || updated != created {
t.Fatalf("timestamps = (%d, %d), want (%d, %d)", created, updated, now-100, now-100)
}
}