Files
Gabriel20xx 937f51b4fb
Lint / Lint (push) Successful in 26s
Tests / Go backend (push) Failing after 1m14s
Tests / Dashboard checks (push) Successful in 52s
Docker / Docker Build & Push (push) Successful in 3m41s
fix: address performance and security findings
- Add PostgreSQL-backed backend and frontend tests to CI
- Harden Android API logging and disable app backups
- Update the performance report with resolved findings
2026-10-19 21:16:08 +00:00

49 lines
1.6 KiB
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)
}
}
func TestChangeEventTypeNamesEachChange(t *testing.T) {
cases := []struct {
name string
initialSync bool
deleted bool
want string
}{
{name: "first sync creates", initialSync: true, want: "created"},
{name: "later edit updates", initialSync: false, want: "updated"},
{name: "tombstone is deleted on first sync", initialSync: true, deleted: true, want: "deleted"},
{name: "tombstone is deleted later", initialSync: false, deleted: true, want: "deleted"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if got := changeEventType(tc.initialSync, tc.deleted); got != tc.want {
t.Fatalf("changeEventType(%v, %v) = %q, want %q", tc.initialSync, tc.deleted, got, tc.want)
}
})
}
}