feat: harden runtime import and frontend verification workflows
Some checks failed
CI / Build & Test (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Release (push) Has been cancelled

This commit is contained in:
phamnazage-jpg
2026-06-04 20:02:36 +08:00
parent 7ce72cbc35
commit 77b7f7f660
32 changed files with 2657 additions and 109 deletions

View File

@@ -0,0 +1,57 @@
package app
import (
"context"
"testing"
"time"
)
// Test utility functions from batch_runtime.go
func TestSleepWithContext_Normal(t *testing.T) {
ctx := context.Background()
start := time.Now()
err := sleepWithContext(ctx, 1*time.Millisecond)
elapsed := time.Since(start)
if err != nil {
t.Errorf("sleep should not error: %v", err)
}
if elapsed < 1*time.Millisecond {
t.Error("should have slept")
}
}
func TestSleepWithContext_Canceled(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
start := time.Now()
err := sleepWithContext(ctx, 100*time.Millisecond)
elapsed := time.Since(start)
if err == nil {
t.Error("canceled context should return error")
}
if elapsed > 10*time.Millisecond {
t.Error("should have returned early due to cancellation")
}
}
func TestFirstNonEmptyString(t *testing.T) {
if firstNonEmptyString("", "", "value") != "value" {
t.Error("should return first non-empty")
}
}
func TestFirstNonEmptyString_First(t *testing.T) {
if firstNonEmptyString("first", "second", "third") != "first" {
t.Error("should return first value when all non-empty")
}
}
func TestFirstNonEmptyString_AllEmpty(t *testing.T) {
if firstNonEmptyString("", "", "") != "" {
t.Error("all empty should return empty")
}
}