python_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package python
  2. import "testing"
  3. // TestPython tests the Python stack analysis functionality.
  4. // It checks if the Name method returns the correct stack name
  5. func TestPython(t *testing.T) {
  6. // Create a new Python stack instance
  7. pythonStack := &Python{}
  8. // Test the Name method
  9. expectedName := "Python"
  10. if pythonStack.Name() != expectedName {
  11. t.Errorf("Expected name %s, got %s", expectedName, pythonStack.Name())
  12. }
  13. // Test the Analyze method with a sample codebase path
  14. codebasePath := "/path/to/python/project"
  15. stackName, err := pythonStack.Analyze(codebasePath)
  16. if err != nil {
  17. t.Errorf("Unexpected error during analysis: %v", err)
  18. }
  19. if stackName != expectedName {
  20. t.Errorf("Expected stack name %s, got %s", expectedName, stackName)
  21. }
  22. }
  23. // TestPythonAnalyzeError tests the Analyze method for error handling.
  24. func TestPythonAnalyzeError(t *testing.T) {
  25. // Create a new Python stack instance
  26. pythonStack := &Python{}
  27. // Test the Analyze method with an invalid codebase path
  28. invalidPath := "/invalid/path/to/python/project"
  29. _, err := pythonStack.Analyze(invalidPath)
  30. if err == nil {
  31. t.Error("Expected an error for invalid codebase path, got nil")
  32. }
  33. }