From 5ce57bcd224e5d3c26e8e0c85e0d2b823c01497d Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Tue, 31 Oct 2023 20:07:53 -0300 Subject: [PATCH] feat: cli e2e tests --- .../src/command/update.rs | 1 - tests/cli/fvm_smoke_tests/fvm_basic.bats | 65 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/crates/fluvio-version-manager/src/command/update.rs b/crates/fluvio-version-manager/src/command/update.rs index 112c6736ab..527cdf55e5 100644 --- a/crates/fluvio-version-manager/src/command/update.rs +++ b/crates/fluvio-version-manager/src/command/update.rs @@ -3,7 +3,6 @@ use anyhow::{Result, Error}; use clap::Args; use colored::Colorize; -use semver::Version; use url::Url; use fluvio_hub_util::HUB_REMOTE; diff --git a/tests/cli/fvm_smoke_tests/fvm_basic.bats b/tests/cli/fvm_smoke_tests/fvm_basic.bats index 22b780c4fe..6108551194 100644 --- a/tests/cli/fvm_smoke_tests/fvm_basic.bats +++ b/tests/cli/fvm_smoke_tests/fvm_basic.bats @@ -50,6 +50,10 @@ setup_file() { FVM_CARGO_TOML_VERSION="$(yq -oy '.package.version' ./crates/fluvio-version-manager/Cargo.toml)" export FVM_CARGO_TOML_VERSION + debug_msg "FVM Cargo.toml Version: $FVM_CARGO_TOML_VERSION" + + VERSION_FILE="$(cat ./VERSION)" + export VERSION_FILE debug_msg "Version File Value: $FVM_CARGO_TOML_VERSION" } @@ -670,3 +674,64 @@ setup_file() { rm -rf $FLUVIO_HOME_DIR assert_success } + +@test "Updates version in stable channel" { + run bash -c '$FVM_BIN self install' + assert_success + + # Sets `fvm` in the PATH using the "env" file included in the installation + source ~/.fvm/env + + # Installs the stable version + run bash -c 'fvm install stable' + assert_success + + # Changes the version set as `stable` channel to $STATIC_VERSION in order to + # force an update. $STATIC_VERSION just to reuse the variable to improve + # readability, it could be any version tag (but stable of course!) + sed -i "" "s/$STABLE_VERSION/$STATIC_VERSION/g" $FVM_HOME_DIR/settings.toml + + # Attempts to update Fluvio + run bash -c 'fvm update' + assert_line --index 0 "info: Updating fluvio stable to version $STABLE_VERSION. Current version is $STATIC_VERSION." + assert_success + + # Removes FVM + run bash -c 'fvm self uninstall --yes' + assert_success + + # Removes Fluvio + rm -rf $FLUVIO_HOME_DIR + assert_success +} + +@test "Updates version in latest channel" { + run bash -c '$FVM_BIN self install' + assert_success + + # Sets `fvm` in the PATH using the "env" file included in the installation + source ~/.fvm/env + + # Installs the stable version + run bash -c 'fvm install latest' + assert_success + + # Changes the version set as `stable` channel to $STATIC_VERSION in order to + # force an update. $STATIC_VERSION just to reuse the variable to improve + # readability. + sed -i "" "s/$VERSION_FILE/$STATIC_VERSION/g" $FVM_HOME_DIR/settings.toml + + # Attempts to update Fluvio + run bash -c 'fvm update' + assert_line --index 0 --partial "info: Updating fluvio latest to version $VERSION_FILE" + assert_line --index 0 --partial "Current version is $STATIC_VERSION+" + assert_success + + # Removes FVM + run bash -c 'fvm self uninstall --yes' + assert_success + + # Removes Fluvio + rm -rf $FLUVIO_HOME_DIR + assert_success +}