git_repository_test.rb revision 03dee28977299b4b40210d9b7842bf85c136ab7d
require 'test_helper'
# Tests a git repository
#
# Author: Eugen Kuksa <eugenk@informatik.uni-bremen.de>
context 'creating and deleting a repository' do
setup do
end
should 'create repository' do
@path_new = "#{@path}_new"
end
should 'delete repository' do
@path_new = "#{@path}_new"
end
end
context 'existing repository' do
setup do
@userinfo = {
time: Time.now
}
end
teardown do
@repository = nil
end
context 'using files' do
setup do
@content = 'Some content'
@message = 'Some commit message'
end
should 'create single commit of a file' do
# removed because of time zone issues
#assert_equal Time.at(@repository.commit_author[:time]), Time.gm(@userinfo[:time])
end
should 'delete a file' do
end
should 'overwrite a file' do
content2 = "#{@content}_2"
message2 = "#{@message}_2"
end
should 'reset state on empty repository with failing commit block' do
end
end
# it is actually empty, but in this test this can't be found out
#assert @repository.empty?
end
should 'reset state with failing commit block' do
end
end
# it is actually equal, but in this test this can't be found out
#assert_equal first_commit_oid, @repository.head_oid
end
end
context 'using folders' do
setup do
@subfolder = 'path'
@content = 'Some content'
@message1 = 'Some commit message1'
@message2 = 'Some commit message2'
@message3 = 'Some commit message3'
end
should 'read the right number of contents in the root folder after adding the first file' do
end
should 'read the right contents in the root folder after adding the first file' do
type: :dir,
}]
end
should 'read the right number of contents in the subfolder after adding the first file' do
end
should 'read the right contents in the subfolder after adding the first file' do
type: :file,
}]
end
should 'read the right number of contents in the root folder after adding the second file' do
end
should 'read the right contents in the root folder after adding the second file' do
type: :dir,
}]
end
should 'read the right number of contents in the subfolder after adding the second file' do
end
should 'read the right contents in the subfolder after adding the second file' do
type: :file,
},{
type: :file,
}]
end
should 'read the right number of contents in the root folder after adding the third file' do
end
should 'read the right contents in the root folder after adding the third file' do
type: :dir,
},{
type: :file,
}]
end
should 'read the right number of contents in the subfolder after adding the third file' do
end
should 'read the right contents in the subfolder after adding the third file' do
type: :file,
},{
type: :file,
}]
end
should 'treat path "/" and empty path equally' do
assert_equal @repository.folder_contents(@commit_add3, '/'), @repository.folder_contents(@commit_add3)
assert_equal @repository.folder_contents(@commit_add3, '/'), @repository.folder_contents(@commit_add3, nil)
end
should 'read the right number of contents in the root folder after deleting the first file' do
end
should 'read the right contents in the root folder after deleting the first file' do
type: :dir,
},{
type: :file,
}]
end
should 'read the right number of contents in the subfolder after deleting the first file' do
end
should 'read the right contents in the subfolder after deleting the first file' do
type: :file,
}]
end
should 'read the right number of contents in the root folder after deleting the second file' do
end
should 'read the right contents in the root folder after deleting the second file' do
type: :file,
}]
end
should 'read the right number of contents in the root folder after deleting the third file' do
end
should 'read the right contents in the root folder after deleting the third file' do
end
end
context 'getting the commit history' do
setup do
@commit_other1 = @repository.commit_file(@userinfo, 'Other content1', 'file2.txt', 'Other File: Add')
@commit_other2 = @repository.commit_file(@userinfo, 'Other content2', 'file2.txt', 'Other File: Change1')
@commit_other3 = @repository.commit_file(@userinfo, 'Other content3', 'file2.txt', 'Other File: Change2')
end
should 'list all commits regarding the whole branch' do
@repository.commits.map{ |c| c[:oid] }
end
end
end
end
end
setup do
@content1 = "Some\ncontent\nwith\nmany\nlines."
@content2 = "Some\ncontent,\nwith\nmany\nlines."
end
end
end
end
end
end
assert_equal @repository.changed_files(@commit1).first[:mime_type], Mime::Type.lookup_by_extension(@file_extension)
end
end
end
end
end
end
end
assert_equal @repository.changed_files(@commit2).first[:mime_type], Mime::Type.lookup_by_extension(@file_extension)
end
end
end
end
end
end
assert_equal @repository.changed_files.first[:type], :delete
end
assert_equal @repository.changed_files.first[:mime_type], Mime::Type.lookup_by_extension(@file_extension)
end
assert_equal @repository.changed_files.first[:mime_category], 'application'
end
end
end
end
end