package interactive import ( "testing" ) // Testing interactive prompts is challenging since they require user input // Here we test the function signatures and basic structure func TestPromptFunctionsExist(t *testing.T) { // Verify that the functions have the expected signatures var _ func(string, string) (string, error) = PromptText var _ func(string) (string, error) = PromptPassword var _ func(string, []string) (string, error) = PromptSelect var _ func(string) (bool, error) = PromptConfirm var _ func(string, int) (int, error) = PromptInt var _ func(string, int, int, int) (int, error) = PromptIntWithRange var _ func(map[string]interface{}) (map[string]interface{}, error) = PromptYamlVariables } // Test the PromptIntWithRange function without mocking func TestPromptIntWithRange_Validation(t *testing.T) { // Since we can't replace the PromptInt function for testing, // we'll test only the behaviors we can verify: // 1. Check the function exists and has the correct signature var promptIntRangeFn func(string, int, int, int) (int, error) = PromptIntWithRange if promptIntRangeFn == nil { t.Error("PromptIntWithRange function is nil") } } // TestPromptYamlVariablesTypes tests the variable handling logic func TestPromptYamlVariablesTypes(t *testing.T) { // We can't test the full function without mocking, but we can // verify that it exists with the right signature var promptYamlVarsFn func(map[string]interface{}) (map[string]interface{}, error) = PromptYamlVariables if promptYamlVarsFn == nil { t.Error("PromptYamlVariables function is nil") } // Skip the actual testing since we can't mock the dependencies t.Skip("PromptYamlVariables requires user input, skipping detailed testing") } // For better testability in the future, consider refactoring the prompt functions like this: /* // Interfaces for prompt functionality that can be mocked for testing type Prompter interface { PromptText(message string, defaultValue string) (string, error) PromptInt(message string, defaultValue int) (int, error) PromptConfirm(message string) (bool, error) // ...other methods } // Implementation using survey type SurveyPrompter struct{} func (p *SurveyPrompter) PromptText(message string, defaultValue string) (string, error) { // Real implementation } // Then in other code: type Handler struct { Prompter Prompter } func (h *Handler) PromptIntWithRange(message string, defaultValue, min, max int) (int, error) { // Use h.Prompter.PromptInt } */