Skip to content

Add Tests #11

@CarlosLeonCode

Description

@CarlosLeonCode

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. For example: "I'm always frustrated when..."
Use bats-core for testing modules.


Describe the solution you'd like

A clear and concise description of what you want to happen.
Example

#!/usr/bin/env bats

# La función setup se ejecuta antes de cada prueba. Es nuestro laboratorio.
setup() {
  # 1. Añadimos los mocks al PATH
  export PATH="$(pwd)/tests/mocks:$PATH"

  # 2. Cargamos el módulo que queremos probar
  source "modules/git.sh"
}

@test "gs | should call 'git status -sb'" {
  # Ejecuta el comando y captura su salida
  run gs
  
  # Afirma que el comando se ejecutó sin errores (status 0)
  [ "$status" -eq 0 ]

  # Afirma que la salida es la que esperamos de nuestro mock
  [ "$output" = "🐙 Mock 'git' was called with args: status -sb" ]
}

@test "gc | should pass commit message correctly" {
  run gc "A test message"
  [ "$status" -eq 0 ]
  [ "$output" = "🐙 Mock 'git' was called with args: commit -m A test message" ]
}

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.


Additional context

Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions