summary: Test '{{ name }}' deployment

environment:
  MODEL: "$(HOST: uuidgen)"

prepare: |
  juju add-model "${MODEL}"

execute: |
  # You will need to change the resource
  juju deploy --model "${MODEL}" "${CRAFT_ARTIFACT}" --resource some-container-image=YOUR_IMAGE_GOES_HERE

  # Wait for all apps on the model to become active.
  juju wait-for application '{{ name }}'

  # Remove all applications and their dependencies
  for app in $(juju status --format=json | jq -r '.applications | keys[]'); do
    juju remove-application --model="${MODEL}" --destroy-storage --force --no-prompt "${app}"
  done

restore: |
  juju destroy-model --no-prompt --force --destroy-storage --no-wait --timeout=60s "${MODEL}"
