refactor: move plugin test helper functions to test_helper.bash

This commit is contained in:
Jose Diaz-Gonzalez
2024-03-13 10:51:08 -04:00
parent cf742bb3e0
commit ca55f58446
2 changed files with 12 additions and 12 deletions

View File

@@ -1,24 +1,12 @@
#!/usr/bin/env bats
load test_helper
TEST_PLUGIN_NAME=smoke-test-plugin
TEST_PLUGIN_GIT_REPO=https://github.com/dokku/${TEST_PLUGIN_NAME}.git
TEST_PLUGIN_LOCAL_REPO="$(mktemp -d)/$TEST_PLUGIN_NAME"
clone_test_plugin() {
git clone "$TEST_PLUGIN_GIT_REPO" "$TEST_PLUGIN_LOCAL_REPO"
}
setup() {
global_setup
clone_test_plugin
}
remove_test_plugin() {
rm -rf $PLUGIN_ENABLED_PATH/$TEST_PLUGIN_NAME $PLUGIN_AVAILABLE_PATH/$TEST_PLUGIN_NAME
rm -rf $TEST_PLUGIN_LOCAL_REPO
}
teardown() {
remove_test_plugin || true
global_teardown

View File

@@ -15,6 +15,9 @@ UUID=$(uuidgen)
TEST_APP="rdmtestapp-${UUID}"
TEST_NETWORK="test-network-${UUID}"
SKIPPED_TEST_ERR_MSG="previous test failed! skipping remaining tests..."
TEST_PLUGIN_NAME=smoke-test-plugin
TEST_PLUGIN_GIT_REPO=https://github.com/dokku/${TEST_PLUGIN_NAME}.git
TEST_PLUGIN_LOCAL_REPO="$(mktemp -d)/$TEST_PLUGIN_NAME"
# global setup() and teardown()
# skips remaining tests on first failure
@@ -45,6 +48,15 @@ cleanup_containers() {
fi
}
clone_test_plugin() {
git clone "$TEST_PLUGIN_GIT_REPO" "$TEST_PLUGIN_LOCAL_REPO"
}
remove_test_plugin() {
rm -rf $PLUGIN_ENABLED_PATH/$TEST_PLUGIN_NAME $PLUGIN_AVAILABLE_PATH/$TEST_PLUGIN_NAME
rm -rf $TEST_PLUGIN_LOCAL_REPO
}
# test functions
flunk() {
{