Sha256: 618b6ea6137ec66ecca70e3a996a60b590706c9cc61c5f24bcd58473bbeba89e

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

#!/usr/bin/env ruby

require 'test/unit'
require 'fileutils'

require 'rubygems/remote_installer'
require 'test/yaml_data'
require 'test/gemutilities'

class TestCachedFetcher < Test::Unit::TestCase
  SOURCE_URI = "http://localhost:12344"
  GEMHOME = "test/temp/writable_cache"

  class MockFetcher
    attr_reader :count
    attr_accessor :size

    def initialize
      @count = 0
      @size = 5
    end

    def fetch_path(path=nil)
    end
    
    def source_index
      @count += 1
    end
  end

  def setup
    make_cache_area(GEMHOME, "http://localhost:12344")
    Gem.clear_paths
    Gem.use_paths(GEMHOME)
    @cf = Gem::CachedFetcher.new(SOURCE_URI, nil)
    @mf = MockFetcher.new
    @cf.instance_variable_set("@fetcher", @mf)
  end

  def test_create
    assert_not_nil @cf
    assert_equal 5, @cf.size
    assert_equal 0, @mf.count
  end

  def test_cache_miss
    @cf.source_index
    assert_equal 1, @mf.count
  end

  def test_cache_hit
    @mf.size = YAML_DATA.size
    @cf.source_index
    assert_equal 0, @mf.count
  end

  def make_cache_area(path, *uris)
    Utilities.make_cache_area(path, *uris)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubygems-update-0.8.6 test/test_cached_fetcher.rb
rubygems-update-0.8.8 test/test_cached_fetcher.rb
rubygems-update-0.8.5 test/test_cached_fetcher.rb
rubygems-update-0.8.3 test/test_cached_fetcher.rb
rubygems-update-0.8.10 test/test_cached_fetcher.rb
rubygems-update-0.8.4 test/test_cached_fetcher.rb