package main import "testing" func TestArtifactIDFromUpload(t *testing.T) { if got := artifactIDFromUpload([]byte(`{"artifactId":"art_1","filename":"a.txt"}`)); got != "art_1" { t.Fatalf("artifactId = %q", got) } if got := artifactIDFromUpload([]byte(`{"id":"art_2"}`)); got != "art_2" { t.Fatalf("id = %q", got) } } func TestAttemptInWindow(t *testing.T) { cases := []struct { started, since, until string want bool }{ {"2026-10-12T13:37:55.091216802Z", "2026-10-12T13:37:57Z", "2026-10-12T13:38:57Z", false}, {"2026-10-12T13:37:57Z", "2026-10-12T13:37:57Z", "2026-10-12T13:38:57Z", true}, {"2026-10-12T13:38:57.000000001Z", "2026-10-12T13:37:57Z", "2026-10-12T13:38:57Z", false}, {"2026-10-12T13:38:10.5Z", "", "", true}, {"not-a-time", "2026-10-12T13:37:57Z", "2026-10-12T13:38:57Z", false}, } for _, tc := range cases { if got := attemptInWindow(tc.started, tc.since, tc.until); got != tc.want { t.Errorf("attemptInWindow(%s, %s, %s) = %v, want %v", tc.started, tc.since, tc.until, got, tc.want) } } }