(t *testing.T)
| 509 | } |
| 510 | |
| 511 | func TestClaudeEngineWithVersion(t *testing.T) { |
| 512 | engine := NewClaudeEngine() |
| 513 | |
| 514 | // Test with custom version |
| 515 | engineConfig := &EngineConfig{ |
| 516 | ID: "claude", |
| 517 | Version: "v1.2.3", |
| 518 | Model: "claude-3-5-sonnet-20241022", |
| 519 | } |
| 520 | |
| 521 | workflowData := &WorkflowData{ |
| 522 | Name: "test-workflow", |
| 523 | EngineConfig: engineConfig, |
| 524 | } |
| 525 | |
| 526 | // Check installation steps for custom version |
| 527 | // Secret validation is now in the activation job; installation has Node.js setup + install = 2 steps |
| 528 | installSteps := engine.GetInstallationSteps(workflowData) |
| 529 | if len(installSteps) != 2 { |
| 530 | t.Fatalf("Expected 2 installation steps (Node.js setup + install), got %d", len(installSteps)) |
| 531 | } |
| 532 | |
| 533 | // Check that install step uses the custom version (second step, index 1) |
| 534 | installStep := strings.Join([]string(installSteps[1]), "\n") |
| 535 | if !strings.Contains(installStep, "npm install -g @anthropic-ai/claude-code@v1.2.3") { |
| 536 | t.Errorf("Expected npm install with custom version v1.2.3 (no --ignore-scripts) in install step:\n%s", installStep) |
| 537 | } |
| 538 | if strings.Contains(installStep, "--ignore-scripts") { |
| 539 | t.Errorf("Expected no --ignore-scripts flag for Claude Code, got:\n%s", installStep) |
| 540 | } |
| 541 | |
| 542 | steps := engine.GetExecutionSteps(workflowData, "test-log") |
| 543 | if len(steps) != 1 { |
| 544 | t.Fatalf("Expected 1 step (execution), got %d", len(steps)) |
| 545 | } |
| 546 | |
| 547 | // Check the main execution step |
| 548 | executionStep := steps[0] |
| 549 | stepContent := strings.Join([]string(executionStep), "\n") |
| 550 | |
| 551 | // Check that claude command is used directly (not npx) |
| 552 | if !strings.Contains(stepContent, "claude --print") { |
| 553 | t.Errorf("Expected claude command in step content:\n%s", stepContent) |
| 554 | } |
| 555 | |
| 556 | // Check that model is set via ANTHROPIC_MODEL env var (not as --model flag) |
| 557 | if !strings.Contains(stepContent, "ANTHROPIC_MODEL: claude-3-5-sonnet-20241022") { |
| 558 | t.Errorf("Expected ANTHROPIC_MODEL env var for model 'claude-3-5-sonnet-20241022' in step content:\n%s", stepContent) |
| 559 | } |
| 560 | if strings.Contains(stepContent, "--model claude-3-5-sonnet-20241022") { |
| 561 | t.Errorf("Model should not be embedded as --model flag in step content:\n%s", stepContent) |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | func TestClaudeEngineWithoutVersion(t *testing.T) { |
| 566 | engine := NewClaudeEngine() |
nothing calls this directly
no test coverage detected