github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/tests/suites/branches/active_branch.sh (about) 1 # Checks juju that juju shows no branches output. 2 run_indicate_active_branch_no_active() { 3 echo 4 5 file="${TEST_DIR}/indicate-active-branch-no-active.log" 6 7 ensure "indicate-active-branch-no-active" "${file}" 8 9 juju deploy jameinel-ubuntu-lite 10 11 wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")" 12 13 check_not_contains "$(juju status)" "Branch" 14 15 if [ "$(juju status --format=json | jq '.branches')" != null ]; then 16 echo "The status shows branches even though we do not use them yet" 17 exit 1 18 fi 19 20 destroy_model "indicate-active-branch-no-active" 21 } 22 23 # Checks juju that juju shows branches output as we are using it 24 run_indicate_active_branch_active() { 25 echo 26 27 file="${TEST_DIR}/indicate-active-branch-active.log" 28 29 ensure "indicate-active-branch-active" "${file}" 30 31 juju deploy jameinel-ubuntu-lite 32 33 juju add-branch bla 34 wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")" 35 36 check_contains "$(juju status)" "bla\*" 37 38 if [ "$(juju status --format=json | jq '.branches.bla.active')" != true ]; then 39 echo "The status does not show active branch" 40 exit 1 41 fi 42 43 juju add-branch testtest 44 wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")" 45 46 # juju status can be slow, we might need to wait for testtest to appear 47 wait_for "active" ".branches.testtest" 48 49 check_contains "$(juju status)" "testtest\*" 50 check_not_contains "$(juju status)" "bla\*" 51 52 STATUS_UNACTIVE=$(juju status --format=json | jq '.branches.bla.active') 53 STATUS_ACTIVE=$(juju status --format=json | jq '.branches.testtest.active') 54 55 if [ "${STATUS_UNACTIVE}" != null ]; then 56 echo "The status shows active branch" 57 exit 1 58 fi 59 60 if [ "${STATUS_ACTIVE}" != true ]; then 61 echo "The status shows active branch" 62 exit 1 63 fi 64 65 destroy_model "indicate-active-branch-active" 66 } 67 68 test_active_branch_output() { 69 if [ "$(skip 'test_active_branch_output')" ]; then 70 echo "==> TEST SKIPPED: test_active_branch_outputtests" 71 return 72 fi 73 74 ( 75 set_verbosity 76 77 cd .. || exit 78 79 run "run_indicate_active_branch_no_active" 80 run "run_indicate_active_branch_active" 81 ) 82 }