Added unit test for Debian importer
This commit is contained in:
parent
785191e2c2
commit
f9279337ed
2 changed files with 88 additions and 0 deletions
|
|
@ -42,4 +42,20 @@ Debshots::Application.configure do
|
||||||
|
|
||||||
# URL prefix leading to the static images that should get delivered by the web server
|
# URL prefix leading to the static images that should get delivered by the web server
|
||||||
config.images_path_prefix = '/screenshots'
|
config.images_path_prefix = '/screenshots'
|
||||||
|
|
||||||
|
# DEB package repositories to parse when running "rake debshots:... tasks"
|
||||||
|
config.package_sources = [
|
||||||
|
{
|
||||||
|
description: 'Development test files', type: 'apt', url: 'lib/tasks/files/',
|
||||||
|
architectures: ['i386', 'amd64']
|
||||||
|
#components: ['main','restricted','universe','multiverse']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
config.images_path = Rails.root.join('public', 'screenshots')
|
||||||
|
|
||||||
|
config.image_sizes = {
|
||||||
|
large: '800x600',
|
||||||
|
small: '160x120',
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
72
test/lib/deb_importer_test.rb
Normal file
72
test/lib/deb_importer_test.rb
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
require 'open-uri' # allows to load URLs using open()
|
||||||
|
require 'deb_importer'
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
include DebImporter
|
||||||
|
|
||||||
|
class PackagesHelperTest < ActionView::TestCase
|
||||||
|
# class PackagesHelperTest < MiniTest::Spec
|
||||||
|
|
||||||
|
test "should be able to parse local Debian repository test files" do
|
||||||
|
|
||||||
|
expected_package_counts = {
|
||||||
|
main: {
|
||||||
|
amd64: 8320,
|
||||||
|
i386: 8082
|
||||||
|
},
|
||||||
|
restricted: {
|
||||||
|
amd64: 21,
|
||||||
|
i386: 21
|
||||||
|
},
|
||||||
|
universe: {
|
||||||
|
amd64: 29406,
|
||||||
|
i386: 29471
|
||||||
|
},
|
||||||
|
multiverse: {
|
||||||
|
amd64: 672,
|
||||||
|
i386: 685
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories = Rails.configuration.package_sources
|
||||||
|
Rails.logger = Logger.new(STDOUT)
|
||||||
|
Rails.logger.level = Logger::INFO
|
||||||
|
# Rails.logger.level = Logger::DEBUG
|
||||||
|
|
||||||
|
Rails.logger.info "Listing configured DEB repositories"
|
||||||
|
|
||||||
|
repositories.each do |repository|
|
||||||
|
wanted_architectures = repository[:architectures]
|
||||||
|
Rails.logger.info "Fetching Release file for repository: #{repository[:url]} with components: #{repository[:components]}"
|
||||||
|
release = DebImporter::Release.new(repository[:url], repository[:components])
|
||||||
|
Rails.logger.info "> Supported architectures are: #{release.architectures}"
|
||||||
|
if wanted_architectures
|
||||||
|
Rails.logger.info "> We only want architectures: #{wanted_architectures}"
|
||||||
|
end
|
||||||
|
Rails.logger.info "> Supported components are: #{release.components}"
|
||||||
|
|
||||||
|
release.components.split.each do |component|
|
||||||
|
Rails.logger.info "> Component: #{component}"
|
||||||
|
release.architectures.split.each do |architecture|
|
||||||
|
if wanted_architectures and not wanted_architectures.include?(architecture)
|
||||||
|
Rails.logger.debug "Architecture #{architecture} not wanted. Skipping."
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
Rails.logger.info ">> Architecture: #{architecture}"
|
||||||
|
|
||||||
|
packages = release.packages(component, architecture)
|
||||||
|
packages_count = packages.count
|
||||||
|
|
||||||
|
if packages
|
||||||
|
Rails.logger.info "#{packages_count} packages found."
|
||||||
|
assert_equal expected_package_counts[component.to_sym][architecture.to_sym],
|
||||||
|
packages_count
|
||||||
|
else
|
||||||
|
Rails.logger.info "No packages."
|
||||||
|
end
|
||||||
|
end # architectures.each
|
||||||
|
end # components.each
|
||||||
|
end # repositories.each
|
||||||
|
end # test
|
||||||
|
end # class
|
||||||
Loading…
Add table
Add a link
Reference in a new issue