Skip to content

Implement Testing Framework for Lagoon CLI Wrapper #7

Description

@coderabbitai

Overview

This issue outlines a step-by-step approach to implement testing for the Lagoon CLI Wrapper repository.

Background

Currently, the repository lacks automated testing. Adding tests will improve code reliability, make future changes safer, and ensure functionality works as expected.

Steps to Implement Testing

1. Setup Testing Framework

  • Add Jest as the test framework
  • Update package.json with test scripts

2. Setup Test Structure

  • Create test directory structure
  • Add test configuration files

3. Mock External Dependencies

  • Create mocks for child_process.exec to avoid actual Lagoon CLI execution
  • Setup test fixtures for sample responses from Lagoon CLI

4. Unit Tests for Core Modules

  • Test lagoon-api.js functions with mocked responses
    • Test parsing logic for instances, projects, environments
    • Test helper functions (e.g., gitUrlToGithubUrl, extractPrNumber)
  • Test logger.js functionality
  • Test lagoon-ssh-key-configurator.js with mocks

5. Integration Tests for Interactive Flows

  • Test main menus and user interaction flows using mocked inquirer
  • Test error handling and edge cases

6. Setup CI Integration

  • Configure GitHub Actions to run tests on pull requests
  • Add test coverage reporting

Acceptance Criteria

  • All core functionality has proper test coverage
  • Tests run successfully in CI environment
  • Documentation is updated with testing information

Additional Notes

  • We should aim for at least 70% test coverage
  • Consider using snapshot testing for interactive CLI outputs
  • Documentation should include how to run tests locally

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions