(t *testing.T)
| 1383 | } |
| 1384 | |
| 1385 | func TestTaskRecoveryLivenessHelpers(t *testing.T) { |
| 1386 | t.Parallel() |
| 1387 | |
| 1388 | live, state, err := taskSessionRuntimeState(context.Background(), &fakeSessionManager{ |
| 1389 | infos: []*session.Info{ |
| 1390 | {ID: "sess-live", State: session.StateActive}, |
| 1391 | }, |
| 1392 | }, "sess-live") |
| 1393 | if err != nil { |
| 1394 | t.Fatalf("taskSessionRuntimeState(live) error = %v", err) |
| 1395 | } |
| 1396 | if !live { |
| 1397 | t.Fatal("taskSessionRuntimeState(live) = false, want true") |
| 1398 | } |
| 1399 | if got, want := state, string(session.StateActive); got != want { |
| 1400 | t.Fatalf("taskSessionRuntimeState(live) state = %q, want %q", got, want) |
| 1401 | } |
| 1402 | |
| 1403 | if got := taskSessionMatchesRecordedSubprocess(nil); got { |
| 1404 | t.Fatal("taskSessionMatchesRecordedSubprocess(nil) = true, want false") |
| 1405 | } |
| 1406 | if got := taskSessionMatchesRecordedSubprocess(&store.SessionLivenessMeta{}); got { |
| 1407 | t.Fatal("taskSessionMatchesRecordedSubprocess(blank) = true, want false") |
| 1408 | } |
| 1409 | startedAt, err := procutil.StartedAt(os.Getpid()) |
| 1410 | if err != nil { |
| 1411 | t.Fatalf("procutil.StartedAt(self) error = %v", err) |
| 1412 | } |
| 1413 | if got := taskSessionMatchesRecordedSubprocess(&store.SessionLivenessMeta{ |
| 1414 | SubprocessPID: os.Getpid(), |
| 1415 | }); got { |
| 1416 | t.Fatal("taskSessionMatchesRecordedSubprocess(missing start time) = true, want false") |
| 1417 | } |
| 1418 | if got := taskSessionMatchesRecordedSubprocess(&store.SessionLivenessMeta{ |
| 1419 | SubprocessPID: os.Getpid(), |
| 1420 | SubprocessStartedAt: &startedAt, |
| 1421 | }); !got { |
| 1422 | t.Fatal("taskSessionMatchesRecordedSubprocess(self) = false, want true") |
| 1423 | } |
| 1424 | if got, want := firstTaskRecoveryDetail("", " detail ", "fallback"), "detail"; got != want { |
| 1425 | t.Fatalf("firstTaskRecoveryDetail() = %q, want %q", got, want) |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | type taskContextOverlayCall struct { |
| 1430 | taskID string |
nothing calls this directly
no test coverage detected