Merge pull request 'fix(backend): embed the IANA time-zone database' (#297) from feature/embed-tzdata into development
CI / changes (push) Successful in 3s
CI / changes (pull_request) Successful in 2s
CI / unit (push) Successful in 12s
CI / integration (push) Successful in 24s
CI / ui (push) Has been skipped
CI / conformance (push) Successful in 11s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 21s
CI / ui (pull_request) Successful in 1m16s
CI / conformance (pull_request) Successful in 11s
CI / gate (push) Successful in 0s
CI / deploy (push) Successful in 1m46s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Has been skipped

This commit was merged in pull request #297.
This commit is contained in:
2026-07-28 14:59:54 +00:00
2 changed files with 54 additions and 0 deletions
+7
View File
@@ -15,6 +15,13 @@ import (
"syscall" "syscall"
"time" "time"
// The IANA time-zone database, embedded in the binary. The image ships one today, but the
// dependency is not one to leave implicit: the taxpayer's zone decides which tax month an
// income is filed under, and the config refuses to boot on a zone it cannot resolve rather
// than silently falling back to UTC and misfiling. Embedding it makes that correctness
// independent of whatever the base image happens to contain.
_ "time/tzdata"
"github.com/google/uuid" "github.com/google/uuid"
"go.uber.org/zap" "go.uber.org/zap"
+47
View File
@@ -202,3 +202,50 @@ func TestLoadGuestReaperDefaultsAndOverride(t *testing.T) {
t.Fatal("Load: expected an error for a non-positive reap interval, got nil") t.Fatal("Load: expected an error for a non-positive reap interval, got nil")
} }
} }
// TestLoadMyNalogTimeZone pins the taxpayer's time zone: it defaults to Europe/Moscow and an
// unresolvable zone is a hard boot failure, never a quiet fall back to UTC.
//
// The offset a receipt carries decides which tax month an income is filed under, so a silent UTC
// default would misfile every near-midnight payment at a month boundary. That is also why the
// backend embeds the IANA database (a blank time/tzdata import in cmd/backend) instead of trusting
// the base image to ship one.
func TestLoadMyNalogTimeZone(t *testing.T) {
base := func(t *testing.T) {
t.Helper()
t.Setenv("BACKEND_POSTGRES_DSN", testDSN)
t.Setenv("BACKEND_DICT_DIR", "/dict")
}
t.Run("defaults to the taxpayer's zone", func(t *testing.T) {
base(t)
t.Setenv("BACKEND_MYNALOG_TZ", "")
c, err := Load()
if err != nil {
t.Fatalf("load: %v", err)
}
if got := c.MyNalog.Location.String(); got != "Europe/Moscow" {
t.Fatalf("time zone = %q, want Europe/Moscow", got)
}
})
t.Run("honours an explicit zone", func(t *testing.T) {
base(t)
t.Setenv("BACKEND_MYNALOG_TZ", "Asia/Yekaterinburg")
c, err := Load()
if err != nil {
t.Fatalf("load: %v", err)
}
if got := c.MyNalog.Location.String(); got != "Asia/Yekaterinburg" {
t.Fatalf("time zone = %q", got)
}
})
t.Run("refuses an unresolvable zone", func(t *testing.T) {
base(t)
t.Setenv("BACKEND_MYNALOG_TZ", "Mars/Olympus_Mons")
if _, err := Load(); err == nil {
t.Fatal("an unknown time zone must fail the boot, not fall back to UTC")
}
})
}