github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/test/integration/test-rename-cmd.sh (about) 1 #!/bin/bash 2 3 # availeble environment varibale 4 # CL_PATH: the path of the command launcher binary 5 # CL_HOME: the path of the command launcher home directory 6 # OUTPUT_DIR: the output folder 7 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 8 9 # clean up the dropin folder 10 rm -rf $CL_HOME/dropins 11 mkdir -p $CL_HOME/dropins 12 13 # copy the example to the dropin folder for the test 14 cp -R $SCRIPT_DIR/../packages-src/bonjour $CL_HOME/dropins 15 16 # run command launcher 17 echo "> test rename command should exist" 18 RESULT=$($CL_PATH) 19 20 echo "$RESULT" | grep 'rename' 21 if [ $? -eq 0 ]; then 22 echo "OK" 23 else 24 echo "KO - should have rename command at root" 25 exit 1 26 fi 27 28 echo "> test rename command autocompletion" 29 RESULT=$($CL_PATH __complete rename "") 30 echo "$RESULT" | grep 'bonjour@@bonjour@dropin' 31 if [ $? -eq 0 ]; then 32 echo "OK" 33 else 34 echo "KO - should auto-complete install command full name" 35 exit 1 36 fi 37 38 echo "> test rename command" 39 RESULT=$($CL_PATH rename bonjour@@bonjour@dropin hi) 40 RESULT=$($CL_PATH) 41 echo "$RESULT" | grep 'hi' 42 if [ $? -eq 0 ]; then 43 echo "OK" 44 else 45 echo "KO - should have 'hi' command" 46 exit 1 47 fi 48 49 RESULT=$($CL_PATH hi) 50 echo "$RESULT" | grep 'bonjour!' 51 if [ $? -eq 0 ]; then 52 echo "OK" 53 else 54 echo "KO - should be able to run 'hi' command" 55 exit 1 56 fi 57 58 echo "> test delete renamed command" 59 RESULT=$($CL_PATH rename --delete bonjour@@bonjour@dropin) 60 RESULT=$($CL_PATH) 61 echo "$RESULT" | grep 'hi' 62 if [ $? -eq 0 ]; then 63 echo "KO - should NOT have 'hi' command" 64 exit 1 65 else 66 echo "OK" 67 fi 68 69 echo "$RESULT" | grep 'bonjour' 70 if [ $? -eq 0 ]; then 71 echo "OK" 72 else 73 echo "KO - should have bonjour command" 74 exit 1 75 fi 76 77 echo "> test rename to reserved command" 78 RESULT=$($CL_PATH rename bonjour@@bonjour@dropin package 2>&1) 79 echo "$RESULT" | grep -s 'package is a reserved command' 80 if [ $? -eq 0 ]; then 81 echo "OK" 82 else 83 echo "KO - should not rename to a reserved command" 84 exit 1 85 fi 86 87 RESULT=$($CL_PATH) 88 echo "$RESULT" 89 echo "$RESULT" | grep 'bonjour' 90 if [ $? -eq 0 ]; then 91 echo "OK" 92 else 93 echo "KO - should still have 'bonjour' command" 94 exit 1 95 fi 96 97 98 echo "> test rename sub command" 99 RESULT=$($CL_PATH rename saybonjour@greeting@bonjour@dropin sayhi 2>&1) 100 if [ $? -eq 0 ]; then 101 echo "OK" 102 else 103 echo "KO - rename should return 0" 104 exit 1 105 fi 106 107 RESULT=$($CL_PATH greeting -h) 108 echo "$RESULT" | grep 'sayhi' 109 if [ $? -eq 0 ]; then 110 echo "OK" 111 else 112 echo "KO - should have sayhi subcommand" 113 exit 1 114 fi 115 116 RESULT=$($CL_PATH greeting sayhi 2>&1) 117 echo "$RESULT" | grep 'bonjour!' 118 if [ $? -eq 0 ]; then 119 echo "OK" 120 else 121 echo "KO - should be able to call 'greeting bonjour' from renamed command" 122 exit 1 123 fi 124 125 echo "> test list all renamed command" 126 RESULT=$($CL_PATH rename --list) 127 echo "$RESULT" | grep -q "sayhi : saybonjour@greeting@bonjour@dropin" 128 if [ $? -eq 0 ]; then 129 echo "OK" 130 else 131 echo "KO - should list all renamed command" 132 exit 1 133 fi 134