forked from idolum-ai/aphelion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_durable_child_test.go
More file actions
64 lines (54 loc) · 1.75 KB
/
Copy pathmain_durable_child_test.go
File metadata and controls
64 lines (54 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//go:build linux
package main
import (
"encoding/json"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/idolum-ai/aphelion/config"
runtimepkg "github.com/idolum-ai/aphelion/runtime"
)
func TestParseDurableChildWakeTime(t *testing.T) {
t.Parallel()
now, err := parseDurableChildWakeTime("")
if err != nil {
t.Fatalf("parseDurableChildWakeTime(empty) err = %v", err)
}
if now.IsZero() {
t.Fatal("parseDurableChildWakeTime(empty) returned zero time")
}
fixed := "2026-04-20T12:34:56.123456789Z"
parsed, err := parseDurableChildWakeTime(fixed)
if err != nil {
t.Fatalf("parseDurableChildWakeTime(RFC3339Nano) err = %v", err)
}
if got := parsed.UTC().Format(time.RFC3339Nano); got != fixed {
t.Fatalf("parsed = %q, want %q", got, fixed)
}
if _, err := parseDurableChildWakeTime("definitely-not-a-time"); err == nil {
t.Fatal("parseDurableChildWakeTime(invalid) err = nil, want parse error")
}
}
func TestRunDurableAgentChildCommandRequiresMessageOrAgent(t *testing.T) {
t.Parallel()
root := t.TempDir()
bootstrapPath := filepath.Join(root, "child-bootstrap.json")
cfg := config.Default()
cfg.Sessions.DBPath = filepath.Join(root, "sessions.db")
raw, err := json.Marshal(runtimepkg.DurableAgentChildBootstrap{Config: cfg})
if err != nil {
t.Fatalf("json.Marshal(bootstrap) err = %v", err)
}
if err := os.WriteFile(bootstrapPath, raw, 0o600); err != nil {
t.Fatalf("WriteFile(bootstrap) err = %v", err)
}
err = runDurableAgentChildCommand([]string{"--bootstrap", bootstrapPath})
if err == nil {
t.Fatal("runDurableAgentChildCommand() err = nil, want missing mode error")
}
if !strings.Contains(err.Error(), "requires --message or --agent") {
t.Fatalf("runDurableAgentChildCommand() err = %v, want missing mode detail", err)
}
}