Sha256: 6d445ec78625dc63f8a8a357eb7b56551dd7cc24753058a8d187b41bd5271df8

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'test_helper'

class HerokuPullTest < Test::Unit::TestCase
  def setup
    HerokuPull.app_name = nil
    stub(HerokuPull).puts
  end

  def test_app_name
    HerokuPull.app_name = "APP_NAME"
    assert_equal "APP_NAME", HerokuPull.app_name
  end

  def test_capture
    expected_cmd = "heroku pgbackups:capture --expire"
    mock(HerokuPull).system expected_cmd

    HerokuPull.capture
  end

  def test_download
    expected_cmd = "wget -O ./tmp/heroku_pull.sql `heroku pgbackups:url`"
    mock(HerokuPull).system expected_cmd

    HerokuPull.download
  end

  def test_restore
    stub(HerokuPull).database { "test_db" }
    expected_cmd = "pg_restore --verbose --clean --no-acl --no-owner -h localhost -d test_db ./tmp/heroku_pull.sql"
    mock(HerokuPull).system expected_cmd

    HerokuPull.restore
  end

  def test_cmd_with_app_name_set
    HerokuPull.app_name = "APP_NAME"
    expected_cmd = "COMMAND --app APP_NAME"

    assert_equal expected_cmd, HerokuPull.cmd_with_app_name("COMMAND")
  end

  def test_cmd_with_app_name_not_set
    expected_cmd = "COMMAND"
    assert_equal expected_cmd, HerokuPull.cmd_with_app_name(expected_cmd)
  end

  def test_filename
    assert_equal "./tmp/heroku_pull.sql", HerokuPull.filename
  end

  def test_database
    assert_equal "test_db", HerokuPull.database('test/config/database.yml')
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heroku_pull-0.0.3 test/cases/heroku_pull_test.rb