From 7cc3bbeb1b97e42ecc235fba6b28ec5503fd5cd6 Mon Sep 17 00:00:00 2001 From: Valentin Todorov Date: Sat, 20 Sep 2025 14:53:39 +0300 Subject: [PATCH] feat: adding github actions tests --- .github/workflows/test.yml | 38 +++++++++++++++++++++++++++++++++ .github/workflows/test_basic.sh | 24 +++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e69de29..159e994 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v3 + + - name: Run shellcheck + run: | + if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then + sudo apt-get install shellcheck + else + brew install shellcheck + fi + shellcheck -S error bin/gh-switch lib/*.sh + + - name: Test installation + run: | + ./install.sh + gh-switch --version + + - name: Test commands + run: | + gh-switch init + echo -e "\n\n\n\n" | gh-switch add test + gh-switch list + gh-switch current \ No newline at end of file diff --git a/.github/workflows/test_basic.sh b/.github/workflows/test_basic.sh index e69de29..319ba17 100644 --- a/.github/workflows/test_basic.sh +++ b/.github/workflows/test_basic.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Simple test suite +set -e + +echo "Testing gh-switch..." + +# Test init +./bin/gh-switch init +[ -d "$HOME/.config/gh-switch" ] || exit 1 + +# Test add (with mock input) +echo -e "~/.ssh/test\nTest User\ntest@example.com\ntestuser\n" | ./bin/gh-switch add test + +# Test list +./bin/gh-switch list | grep -q "test" || exit 1 + +# Test use +./bin/gh-switch use test --global + +# Test current +./bin/gh-switch current | grep -q "test" || exit 1 + +echo "All tests passed!" \ No newline at end of file