Skip to content

Commit

Permalink
feat: cli e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanBorai committed Nov 1, 2023
1 parent 59663a2 commit b592395
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crates/fluvio-version-manager/src/command/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -32,7 +31,7 @@ impl UpdateOpt {
if channel.is_version_tag() {
// Abort early if the user is not using a Channel and instead has
// a static tag set as active
notify.info("Cannot update a static version tag. You must use a Channel.");
notify.info("Cannot update a static version tag. You must use a channel.");
return Ok(());
}

Expand Down Expand Up @@ -91,7 +90,7 @@ impl UpdateOpt {
async fn fetch_latest_version(&self, channel: &Channel) -> Result<PackageSet> {
if channel.is_version_tag() {
return Err(Error::msg(
"Cannot update a static version tag. You must use a Channel.",
"Cannot update a static version tag. You must use a channel.",
));
}

Expand Down
96 changes: 96 additions & 0 deletions tests/cli/fvm_smoke_tests/fvm_basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -670,3 +674,95 @@ setup_file() {
rm -rf $FLUVIO_HOME_DIR
assert_success
}

@test "Updates version in 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!)
#
# This wont work in macOS because the sed command is different there
sed -i "s/$STABLE_VERSION/$STATIC_VERSION/g" $FVM_HOME_DIR/settings.toml

# Checks active version
run bash -c 'fvm current'
assert_line --index 0 "$STATIC_VERSION (stable)"
assert_success

# 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

# Checks active version
run bash -c 'fvm current'
assert_line --index 0 "$STABLE_VERSION (stable)"
assert_success

# Removes FVM
run bash -c 'fvm self uninstall --yes'
assert_success

# Removes Fluvio
rm -rf $FLUVIO_HOME_DIR
assert_success
}

@test "Do not updates version in static tag" {
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 $STATIC_VERSION'
assert_success

# Attempts to update Fluvio
run bash -c 'fvm update'
assert_line --index 0 "info: Cannot update a static version tag. You must use a channel."
assert_success

# Removes FVM
run bash -c 'fvm self uninstall --yes'
assert_success

# Removes Fluvio
rm -rf $FLUVIO_HOME_DIR
assert_success
}

@test "Renders message when already up-to-date" {
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'
assert_success

# Attempts to update Fluvio
run bash -c 'fvm update'
assert_line --index 0 "done: You are already up to date"
assert_success

# Removes FVM
run bash -c 'fvm self uninstall --yes'
assert_success

# Removes Fluvio
rm -rf $FLUVIO_HOME_DIR
assert_success
}

0 comments on commit b592395

Please sign in to comment.