MCPcopy Create free account
hub / github.com/astercloud/aster / TestGenerateIDs

Function TestGenerateIDs

pkg/executionplan/types_test.go:429–459  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

427}
428
429func 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
461func containsPrefix(s, prefix string) bool {
462 return len(s) >= len(prefix) && s[:len(prefix)] == prefix

Callers

nothing calls this directly

Calls 4

AddStepMethod · 0.95
NewExecutionPlanFunction · 0.85
containsPrefixFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected