1
|
require 'rubygems'
|
2
|
require 'minitest/autorun'
|
3
|
|
4
|
require './test/support/repository_support'
|
5
|
require './lib/runcible'
|
6
|
|
7
|
module Extensions
|
8
|
module TestIsoRepositoryBase
|
9
|
def setup
|
10
|
@support = RepositorySupport.new('iso')
|
11
|
@extension = TestRuncible.server.extensions.repository
|
12
|
end
|
13
|
end
|
14
|
|
15
|
class TestIsoRepositoryCreate < MiniTest::Unit::TestCase
|
16
|
include TestIsoRepositoryBase
|
17
|
|
18
|
def setup
|
19
|
super
|
20
|
@repo_url = "file://#{RepositorySupport::FIXTURE_PATH}/iso"
|
21
|
@repo_id = RepositorySupport.repo_id
|
22
|
end
|
23
|
|
24
|
def teardown
|
25
|
@support.destroy_repo(@repo_id)
|
26
|
super
|
27
|
end
|
28
|
|
29
|
def test_create_with_importer_and_distributors_objects
|
30
|
distributors = [Runcible::Models::IsoDistributor.new('path', true, true, :id => 'iso_distributor')]
|
31
|
importer = Runcible::Models::IsoImporter.new(:feed => @repo_url)
|
32
|
|
33
|
response = @extension.create_with_importer_and_distributors(@repo_id, importer, distributors)
|
34
|
assert_equal 201, response.code
|
35
|
|
36
|
response = @extension.retrieve(@repo_id, :details => true)
|
37
|
assert_equal @repo_id, response['id']
|
38
|
assert_equal 'iso_importer', response['importers'].first['importer_type_id']
|
39
|
end
|
40
|
|
41
|
def test_sync
|
42
|
@support.create_repo(:importer => true)
|
43
|
response = @support.sync_repo
|
44
|
assert_async_response(response)
|
45
|
end
|
46
|
|
47
|
def test_file_ids
|
48
|
@support.create_and_sync_repo(:importer => true)
|
49
|
response = @extension.file_ids(RepositorySupport.repo_id)
|
50
|
refute_empty response
|
51
|
end
|
52
|
|
53
|
def test_files
|
54
|
@support.create_and_sync_repo(:importer => true)
|
55
|
response = @extension.files(RepositorySupport.repo_id)
|
56
|
refute_empty response
|
57
|
end
|
58
|
end
|
59
|
end
|