(t *testing.T)
| 427 | } |
| 428 | |
| 429 | func TestGenerateIDs(t *testing.T) { |
| 430 | // Test that IDs have expected prefixes |
| 431 | plan := NewExecutionPlan("Test") |
| 432 | if plan.ID == "" { |
| 433 | t.Error("plan ID should not be empty") |
| 434 | } |
| 435 | if len(plan.ID) < 10 { |
| 436 | t.Error("plan ID should be at least 10 characters") |
| 437 | } |
| 438 | if !containsPrefix(plan.ID, "plan_") { |
| 439 | t.Errorf("plan ID should start with 'plan_', got %s", plan.ID) |
| 440 | } |
| 441 | |
| 442 | step := plan.AddStep("tool", "step", nil) |
| 443 | if step.ID == "" { |
| 444 | t.Error("step ID should not be empty") |
| 445 | } |
| 446 | if len(step.ID) < 10 { |
| 447 | t.Error("step ID should be at least 10 characters") |
| 448 | } |
| 449 | if !containsPrefix(step.ID, "step_") { |
| 450 | t.Errorf("step ID should start with 'step_', got %s", step.ID) |
| 451 | } |
| 452 | |
| 453 | // Test that multiple plans have different IDs (with some tolerance) |
| 454 | time.Sleep(10 * time.Millisecond) |
| 455 | plan2 := NewExecutionPlan("Test 2") |
| 456 | if plan.ID == plan2.ID { |
| 457 | t.Errorf("two plans should have different IDs: %s vs %s", plan.ID, plan2.ID) |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | func containsPrefix(s, prefix string) bool { |
| 462 | return len(s) >= len(prefix) && s[:len(prefix)] == prefix |
nothing calls this directly
no test coverage detected