Add full test suite with unit, integration, and E2E smoke tests.
Introduce test.bat orchestrating Go/Vitest/Playwright phases, expand coverage across server, agent, and dashboard, and document in tests/README.md.
This commit is contained in:
31
agent/client/jobs_test.go
Normal file
31
agent/client/jobs_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestJobPayloadDetectsServerError(t *testing.T) {
|
||||
raw := json.RawMessage(`{"error":"pool not connected"}`)
|
||||
if !jobPayloadHasError(raw) {
|
||||
t.Fatal("expected error detection")
|
||||
}
|
||||
msg, ok := jobPayloadErrorMessage(raw)
|
||||
if !ok || msg != "pool not connected" {
|
||||
t.Fatalf("unexpected message: %q ok=%v", msg, ok)
|
||||
}
|
||||
}
|
||||
|
||||
func TestJobPayloadNoErrorOnValidJob(t *testing.T) {
|
||||
raw := json.RawMessage(`{"job_id":"abc","blob":"deadbeef","height":1}`)
|
||||
if jobPayloadHasError(raw) {
|
||||
t.Fatal("valid job should not report error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestJobPayloadEmptyBlobNotErrorField(t *testing.T) {
|
||||
raw := json.RawMessage(`{"job_id":"abc","blob":""}`)
|
||||
if jobPayloadHasError(raw) {
|
||||
t.Fatal("empty blob is not an error field")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user