<commit_before># encoding: utf-8
#--
#   Copyright (C) 2012 Gitorious AS
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#++
require "test_helper"
require "dolt/git/repository"
require "time"

describe Dolt::Git::Repository do
  include EM::MiniTest::Spec
  before { @repository = Dolt::Git::Repository.new(".") }

  describe "#submodules" do
    it "returns deferrable" do
      deferrable = @repository.submodules("master")
      assert deferrable.respond_to?(:callback)
      assert deferrable.respond_to?(:errback)
    end

    it "yields list of submodules" do
      @repository.submodules("c1f6cd9").callback do |submodules|
        url = "git://gitorious.org/gitorious/ui3.git"
        assert_equal [{ :path => "vendor/ui", :url => url }], submodules
        done!
      end
    wait!
    end

    it "resolves with empty array if no submodules" do
      @repository.submodules("26139a3").callback do |submodules|
        assert_equal [], submodules
        done!
      end
      wait!
    end
  end

  describe "#tree" do
    it "includes submodule data for trees" do
      @repository.tree("master", "vendor").callback do |tree|
        assert_equal({
          :type => :submodule,
          :filemode => 57344,
          :name => "ui",
          :oid => "2b05baa5a2e626cb1a4c4b30299c1db5490979b7",
          :url => "git://gitorious.org/gitorious/ui3.git"
        }, tree.entries.first)
        done!
      end
      wait!
    end
  end

  describe "#blame" do
    it "returns deferrable" do
      deferrable = @repository.blame("master", "Gemfile")
      assert deferrable.respond_to?(:callback)
      assert deferrable.respond_to?(:errback)
    end

    it "yields blame" do
      @repository.blame("master", "Gemfile").callback do |blame|
        assert Dolt::Git::Blame === blame
        done!
      end
      wait!
    end
  end

  describe "#log" do
    it "returns deferrable" do
      deferrable = @repository.log("master", "Gemfile", 1)
      assert deferrable.respond_to?(:callback)
      assert deferrable.respond_to?(:errback)
    end
<commit_msg>Make test less volatile - don't look up 'master'<commit_after># encoding: utf-8
#--
#   Copyright (C) 2012 Gitorious AS
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#++
require "test_helper"
require "dolt/git/repository"
require "time"

describe Dolt::Git::Repository do
  include EM::MiniTest::Spec
  before { @repository = Dolt::Git::Repository.new(".") }

  describe "#submodules" do
    it "returns deferrable" do
      deferrable = @repository.submodules("master")
      assert deferrable.respond_to?(:callback)
      assert deferrable.respond_to?(:errback)
    end

    it "yields list of submodules" do
      @repository.submodules("c1f6cd9").callback do |submodules|
        url = "git://gitorious.org/gitorious/ui3.git"
        assert_equal [{ :path => "vendor/ui", :url => url }], submodules
        done!
      end
    wait!
    end

    it "resolves with empty array if no submodules" do
      @repository.submodules("26139a3").callback do |submodules|
        assert_equal [], submodules
        done!
      end
      wait!
    end
  end

  describe "#tree" do
    it "includes submodule data for trees" do
      @repository.tree("3dc532f", "vendor").callback do |tree|
        assert_equal({
          :type => :submodule,
          :filemode => 57344,
          :name => "ui",
          :oid => "d167e3e1c17a27e4cf459dd380670801b0659659",
          :url => "git://gitorious.org/gitorious/ui3.git"
        }, tree.entries.first)
        done!
      end
      wait!
    end
  end

  describe "#blame" do
    it "returns deferrable" do
      deferrable = @repository.blame("master", "Gemfile")
      assert deferrable.respond_to?(:callback)
      assert deferrable.respond_to?(:errback)
    end

    it "yields blame" do
      @repository.blame("master", "Gemfile").callback do |blame|
        assert Dolt::Git::Blame === blame
        done!
      end
      wait!
    end
  end

  describe "#log" do
    it "returns deferrable" do
      deferrable = @repository.log("master", "Gemfile", 1)
      assert deferrable.respond_to?(:callback)
      assert deferrable.respond_to?(:errback)
    end

{'fraction_non_alphanumeric': 0.10747147589252852, 'fraction_numerical': 0.019138755980861243, 'mean_word_length': 2.8437057991513437, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4130435', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1656, 'n_words': 519}