Sha256: 129e3b8897fe81eeed8ab6183d0887ba87b716e1b25a544bf69fb84efdec2395

Contents?: true

Size: 1.85 KB

Versions: 23

Compression:

Stored size: 1.85 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require 'fake_rpm_site'
require 'new_relic/cli/command'

class DeploymentTest < Minitest::Test
  def setup
    $rpm_site ||= NewRelic::FakeRpmSite.new
    $rpm_site.reset
    $rpm_site.run
  end

  def test_deploys_to_configured_application
    cap_it
    assert_deployment_value("application_id", "test")
  end

  def test_deploys_with_commandline_parameter
    # Capistrano 3 doesn't provide built-in commandline params -> settings
    # We wire our own up via ENV to test setting out setting custom values
    env = {
      'NEWRELIC_CAPISTRANO_USER'        => "Optimus Prime",
      'NEWRELIC_CAPISTRANO_APPNAME'     => "Tesseract",
      'NEWRELIC_CAPISTRANO_REVISION'    => "C-001",
      'NEWRELIC_CAPISTRANO_CHANGELOG'   => "The greatest weakness of most humans is their hesitancy to tell others they love them while they're alive.",
    }

    cap_it(env)

    assert_deployment_value("user",           "Optimus Prime")
    assert_deployment_value("application_id", "Tesseract")
    assert_deployment_value("revision",       "C-001")
    assert_deployment_value("changelog",      "The greatest weakness of most humans is their hesitancy to tell others they love them while they're alive.")
  end

  def test_newrelic_revision_override
  end

  def assert_deployment_value(key, value)
    assert_equal(1, $rpm_site.requests.count)
    assert_equal(value, $rpm_site.requests.first["deployment"][key])
  end

  def cap_it(custom_env={})
    cmd = "cap production newrelic:notice_deployment"
    default_env = { 'FAKE_RPM_SITE_PORT' => $rpm_site.port.to_s }
    output = with_environment(default_env.merge(custom_env)) do
      `#{cmd}`
    end
    assert $?.success?, "cap command '#{cmd}' failed with output: #{output}"
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
newrelic_rpm-3.17.2.327 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.17.1.326 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.17.0.325 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.16.3.323 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.16.2.321 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.16.1.320 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.16.0.318 test/multiverse/suites/capistrano/deployment_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.15.2.317 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.15.1.316 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.15.0.314 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.14.3.313 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.14.2.312 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.14.1.311 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.14.0.305 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.13.2.302 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.13.1.300 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.13.0.299 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.12.1.298 test/multiverse/suites/capistrano/deployment_test.rb
newrelic_rpm-3.12.0.288 test/multiverse/suites/capistrano/deployment_test.rb