package app import ( "encoding/json" "headshed/infctl-cli/config" "os" "path/filepath" "testing" ) // Test only pipeline execution and shell command running func TestRunPipeline(t *testing.T) { tempDir, err := os.MkdirTemp("", "smoke-test") if err != nil { t.Fatalf("Failed to create temp directory: %v", err) } defer os.RemoveAll(tempDir) // Create a test script scriptPath := filepath.Join(tempDir, "good.sh") scriptContent := "#!/bin/bash\necho 'Good script executed'\nexit 0" if err := os.WriteFile(scriptPath, []byte(scriptContent), 0755); err != nil { t.Fatalf("Failed to create script: %v", err) } // Create a test JSON pipeline file pipeline := []PipelineStep{ {Name: "Good Step", Function: "RunCommand", Params: []string{scriptPath}, RetryCount: 0, ShouldAbort: false}, } pipelineFile := filepath.Join(tempDir, "pipeline.json") pipelineData, err := json.Marshal(pipeline) if err != nil { t.Fatalf("Failed to marshal pipeline: %v", err) } if err := os.WriteFile(pipelineFile, pipelineData, 0644); err != nil { t.Fatalf("Failed to write pipeline file: %v", err) } // Set up AppState app := &AppState{ Config: config.BaseConfig{}, Project: config.ProjectConfig{ DeploymentFile: pipelineFile, }, } // Run the pipeline err = app.RunJsonDeployment() if err != nil { t.Errorf("Expected no error, got: %v", err) } } // Removed randomString: not needed for current tests // Removed TestK3DNamespaceCreation: k3d and k8s namespace logic is no longer part of the app // Removed TestSetUpNewProject: advanced project setup logic is no longer part of the app