Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions .github/workflows/test_basic.sh
Original file line number Diff line number Diff line change
@@ -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!"
Loading