Sha256: 7afa517c8d1f4ba6c848775a2553ff9eb1dfc0522e663fc52c898196c0b7dd78

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))

class BugCrashOnDebug < Test::Unit::TestCase
  include BugTestServerSetupTeardown

  def test_on_progress_raise
    c = Curl::Easy.new("http://127.0.0.1:#{@port}/test")
    c.on_progress do|x|
      raise "error"
    end
    c.perform

    assert false, "should not reach this point"

  rescue => e
    assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
    c.close
  end

  def test_on_progress_abort
    # see: https://github.com/taf2/curb/issues/192,
    # to pass:
    # 
    # c = Curl::Easy.new('http://127.0.0.1:9999/test')
    # c.on_progress do|x|
    #   puts "we're in the progress callback"
    #   false
    # end
    # c.perform
    # 
    #  notice no return keyword
    #
    c = Curl::Easy.new("http://127.0.0.1:#{@port}/test")
    did_progress = false
    c.on_progress do|x|
      did_progress = true
      return false
    end
    c.perform
    assert did_progress

    assert false, "should not reach this point"

  rescue => e
    assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
    c.close
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
curb-1.0.6 tests/bug_crash_on_progress.rb
curb-1.0.5 tests/bug_crash_on_progress.rb
curb-1.0.4 tests/bug_crash_on_progress.rb