test: regression tests for all audit gaps — 6 enhanced + 4 new packages
Telegram: splitLongMessage (8 cases), isChatAllowed, updateMetadata (4 cases), panicRecoveryMiddleware, updateLoggingMiddleware, authorizedMessage, stop-while-stopped Container: error paths, payload round-trip, overwrite, minimal payload Events: buffer defaults, subscribe-after-close, double-close safety, slow-subscriber isolation, multi-subscriber ordering, publish timestamping NATS RPC: envelope edge cases, JSON round-trip, request timeout, rollback NellDB: empty store (6 ops), concurrent enqueue/claim (20 goroutines), context cancellation, oversized payload clipping, unmarshalable data, status transitions, events ordering, recover stale, clear terminal Gateway tasks: empty/long title, idempotent enqueue, chat label New packages with tests (formerly zero-test): internal/gate (220 lines), internal/gate/gateextract, internal/plugin/pluginextract, internal/workflow/wfextract All 37 packages pass. Fixes regression gaps from audit.
This commit is contained in:
1 parent
8356863712
commit
e8f78dd0d5
12 files changed
+1327
-2
No files matched your search
@@ -111,3 +111,100 @@ func TestTaskPayloadWrittenAsVolumeFile(t *testing.T) {
|
||||
}
|
||||
_ = payload
|
||||
}
|
||||
|
||||
// ── Regression tests for error paths ────────────────────────────────
|
||||
|
||||
func TestWriteTaskJSONNonexistentDir(t *testing.T) {
|
||||
err := WriteTaskJSON("/nonexistent/path/that/does/not/exist", TaskPayload{ID: 1})
|
||||
if err == nil {
|
||||
t.Error("expected error writing to nonexistent directory")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteTaskJSONEmptyWorkspace(t *testing.T) {
|
||||
err := WriteTaskJSON("", TaskPayload{ID: 1})
|
||||
if err == nil {
|
||||
t.Error("expected error with empty workspace path")
|
||||
}
|
||||
}
|
||||
|
||||
func TestTaskPayloadRoundTrip(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
payload := TaskPayload{
|
||||
ID: 99,
|
||||
Owner: "test-owner",
|
||||
Repo: "test-repo",
|
||||
Number: 42,
|
||||
Title: "test title",
|
||||
Body: "test body",
|
||||
Labels: []string{"a", "b"},
|
||||
Workflow: "tdd",
|
||||
Branch: "feature/x",
|
||||
Plan: "plan text",
|
||||
}
|
||||
|
||||
if err := WriteTaskJSON(dir, payload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(filepath.Join(dir, "task.json"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var decoded TaskPayload
|
||||
if err := json.Unmarshal(data, &decoded); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if decoded.ID != payload.ID {
|
||||
t.Errorf("ID = %d", decoded.ID)
|
||||
}
|
||||
if decoded.Owner != payload.Owner {
|
||||
t.Errorf("Owner = %q", decoded.Owner)
|
||||
}
|
||||
if decoded.Branch != payload.Branch {
|
||||
t.Errorf("Branch = %q", decoded.Branch)
|
||||
}
|
||||
if decoded.Plan != payload.Plan {
|
||||
t.Errorf("Plan = %q", decoded.Plan)
|
||||
}
|
||||
if len(decoded.Labels) != 2 {
|
||||
t.Errorf("Labels = %v", decoded.Labels)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteTaskJSONOverwrite(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
p1 := TaskPayload{ID: 1, Title: "first"}
|
||||
p2 := TaskPayload{ID: 2, Title: "second"}
|
||||
|
||||
WriteTaskJSON(dir, p1)
|
||||
WriteTaskJSON(dir, p2) // overwrite
|
||||
|
||||
data, _ := os.ReadFile(filepath.Join(dir, "task.json"))
|
||||
var decoded TaskPayload
|
||||
json.Unmarshal(data, &decoded)
|
||||
|
||||
if decoded.ID != 2 || decoded.Title != "second" {
|
||||
t.Errorf("expected second payload, got ID=%d Title=%q", decoded.ID, decoded.Title)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteTaskJSONMinimalPayload(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
payload := TaskPayload{ID: 1}
|
||||
|
||||
if err := WriteTaskJSON(dir, payload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
data, _ := os.ReadFile(filepath.Join(dir, "task.json"))
|
||||
var decoded TaskPayload
|
||||
json.Unmarshal(data, &decoded)
|
||||
|
||||
if decoded.ID != 1 {
|
||||
t.Error("minimal payload ID mismatch")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user