Commit 25163ff7 authored by Thong Kuah's avatar Thong Kuah
Browse files

deploy_name() and test happy path

parent b546f3aa
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -143,6 +143,26 @@ test-persist-environment-url:
    - persist_environment_url
    - grep review-app.example.com environment_url.txt

test-deploy-name:
  stage: test
  image: "$BUILD_IMAGE_NAME"
  variables:
    CI_ENVIRONMENT_SLUG: production
  script:
    - source /build/deploy-helpers.sh
    - name=$(deploy_name "stable")
    - |
      if [[ $name != "production" ]]; then
        echo "$name should equal 'production'"
        exit 1
      fi
    - name=$(deploy_name "canary")
    - |
      if [[ $name != "production-canary" ]]; then
        echo "$name should equal 'production-canary'"
        exit 1
      fi

before_script:
  - |
    function expected_error() {
+13 −0
Original line number Diff line number Diff line
@@ -75,3 +75,16 @@ function create_secret() {
function persist_environment_url() {
  echo $CI_ENVIRONMENT_URL > environment_url.txt
}

## Helper functions

function deploy_name() {
  name="$CI_ENVIRONMENT_SLUG"
  track="${1-stable}"

  if [[ "$track" != "stable" ]]; then
    name="$name-$track"
  fi

  echo $name
}