-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add install script tests and enhance install-cli.sh for existin… #670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
41c7046
feat: add install script tests and enhance install-cli.sh for existin…
sofusalbertsen 3b94dd7
refactor: remove Homebrew installation step from install script tests
sofusalbertsen 7c2dbb0
fix: improve existing installation check for Kosli CLI and handle Hom…
sofusalbertsen 1cc5836
fix: remove debug print for existing Kosli installation path
sofusalbertsen 3a66bf3
fix: format and improve token parsing in test_install_script.sh
sofusalbertsen 93b8700
feat: add token support to install script tests for improved authenti…
sofusalbertsen c8acc91
Merge branch 'main' of github.com:kosli-dev/cli into wip/test-install…
sofusalbertsen 5423cfa
fix: streamline version retrieval in test installation script
sofusalbertsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # --- Configuration --- | ||
| TOKEN="" | ||
|
|
||
| # Parse arguments for the test script itself, primarily to pass --token | ||
| while [[ "$#" -gt 0 ]]; do | ||
| case $1 in | ||
| --token) | ||
| if [[ -n "$2" && "$2" != --* ]]; then | ||
| TOKEN="$2" | ||
| shift | ||
| else | ||
| echo "Error: --token requires a value" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| *) echo "Unknown parameter: $1"; exit 1 ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| # Helper to construct command | ||
| run_install() { | ||
| local cmd="./install-cli.sh" | ||
| if [ -n "$TOKEN" ]; then | ||
| cmd="$cmd --token $TOKEN" | ||
| fi | ||
| # Add other arguments passed to function | ||
| cmd="$cmd $@" | ||
| echo "Running: $cmd" | ||
| $cmd | ||
| } | ||
|
|
||
| # Colors for output | ||
| GREEN='\033[0;32m' | ||
| RED='\033[0;31m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| log_info() { | ||
| echo -e "${GREEN}[INFO] $1${NC}" | ||
| } | ||
|
|
||
| log_error() { | ||
| echo -e "${RED}[ERROR] $1${NC}" | ||
| } | ||
|
|
||
|
|
||
| # Test 1: Install specific version | ||
| SPECIFIC_VERSION="v2.11.40" | ||
| log_info "Test 1: Installing specific version ${SPECIFIC_VERSION}..." | ||
|
|
||
| # We pass --version as requested by the user | ||
| run_install --version "${SPECIFIC_VERSION}" --debug | ||
|
|
||
| if ! command -v kosli &> /dev/null; then | ||
| log_error "Kosli CLI not found after installation" | ||
| exit 1 | ||
| fi | ||
|
|
||
| INSTALLED_VERSION=$(kosli version -s) | ||
| log_info "Installed version: ${INSTALLED_VERSION}" | ||
|
|
||
| if [[ "${INSTALLED_VERSION}" == "${SPECIFIC_VERSION}" ]]; then | ||
| log_info "✅ Specific version installed successfully" | ||
| else | ||
| log_info "Expected ${SPECIFIC_VERSION}, got ${INSTALLED_VERSION}" | ||
| log_error "❌ Version mismatch" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Test 2: Upgrade to latest version | ||
| log_info "Test 2: Upgrading to latest version..." | ||
| run_install --debug | ||
|
|
||
| LATEST_INSTALLED_VERSION=$(kosli version | grep -o "v[0-9]\+\.[0-9]\+\.[0-9]\+") | ||
| log_info "Installed version after update: ${LATEST_INSTALLED_VERSION}" | ||
|
|
||
| # Simple check to ensure version changed (assuming latest > specific) | ||
| if [[ "${LATEST_INSTALLED_VERSION}" != "${SPECIFIC_VERSION}" ]]; then | ||
| log_info "✅ Version updated successfully (from ${SPECIFIC_VERSION} to ${LATEST_INSTALLED_VERSION})" | ||
| else | ||
| log_error "❌ Version did not update" | ||
| exit 1 | ||
| fi | ||
|
|
||
| log_info "🎉 All installation tests passed!" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Note: set -e is intentionally omitted here to allow manual exit code checking. | ||
|
|
||
| # --- Configuration --- | ||
| TOKEN="" | ||
|
|
||
| # Parse arguments for the test script itself, primarily to pass --token | ||
| while [[ "$#" -gt 0 ]]; do | ||
| case $1 in | ||
| --token) | ||
| if [[ -n "$2" && "$2" != --* ]]; then | ||
| TOKEN="$2" | ||
| shift | ||
| else | ||
| echo "Error: --token requires a value" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| *) echo "Unknown parameter: $1"; exit 1 ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| # Helper to construct command | ||
| run_install() { | ||
| local cmd="./install-cli.sh" | ||
| if [ -n "$TOKEN" ]; then | ||
| cmd="$cmd --token $TOKEN" | ||
| fi | ||
| # Add other arguments passed to function | ||
| cmd="$cmd $@" | ||
| echo "Running: $cmd" | ||
| $cmd | ||
| } | ||
|
|
||
| # Run the install script | ||
| run_install | ||
|
|
||
| # Capture the exit code of the install script | ||
| EXIT_CODE=$? | ||
|
|
||
| # Check if the exit code is 1 (expected failure due to existing brew installation) | ||
| if [ $EXIT_CODE -eq 1 ]; then | ||
| echo "Success: install-cli.sh detected existing Homebrew installation and exited with 1." | ||
| exit 0 | ||
| else | ||
| echo "Failure: install-cli.sh did not exit with 1. Actual exit code: $EXIT_CODE" | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.