1
|
require 'rubygems'
|
2
|
require 'minitest/autorun'
|
3
|
require 'minitest/mock'
|
4
|
require './lib/runcible'
|
5
|
require './test/support/repository_support'
|
6
|
|
7
|
module Extensions
|
8
|
class UnitCopyBase < MiniTest::Unit::TestCase
|
9
|
def self.clone_name
|
10
|
RepositorySupport.repo_id + '_clone'
|
11
|
end
|
12
|
|
13
|
def self.before_suite
|
14
|
self.support = RepositorySupport.new
|
15
|
self.support.repo_url = self.repo_url if respond_to?(:repo_url)
|
16
|
|
17
|
if respond_to?(:extension_class)
|
18
|
self.support.destroy_repo(clone_name)
|
19
|
self.support.destroy_repo
|
20
|
self.support.create_and_sync_repo(:importer => true)
|
21
|
TestRuncible.server.extensions.repository.create_with_importer(clone_name, :id => 'yum_importer')
|
22
|
end
|
23
|
end
|
24
|
|
25
|
def self.after_suite
|
26
|
if respond_to?(:extension_class)
|
27
|
self.support.destroy_repo(clone_name)
|
28
|
self.support.destroy_repo
|
29
|
end
|
30
|
end
|
31
|
|
32
|
def units(repo)
|
33
|
TestRuncible.server.extensions.repository.unit_search(repo,
|
34
|
:type_ids => [self.class.extension_class.class.content_type])
|
35
|
end
|
36
|
|
37
|
def unit_ids(repo)
|
38
|
units(repo).map { |i| i['unit_id'] }
|
39
|
end
|
40
|
end
|
41
|
|
42
|
class UnitUnassociateBase < MiniTest::Unit::TestCase
|
43
|
def self.clone_name
|
44
|
RepositorySupport.repo_id + '_clone'
|
45
|
end
|
46
|
|
47
|
def self.before_suite
|
48
|
self.support = RepositorySupport.new
|
49
|
self.support.repo_url = self.repo_url if respond_to?(:repo_url)
|
50
|
|
51
|
if respond_to?(:extension_class)
|
52
|
self.support.create_and_sync_repo(:importer => true)
|
53
|
TestRuncible.server.extensions.repository.create_with_importer(clone_name, :id => 'yum_importer')
|
54
|
end
|
55
|
end
|
56
|
|
57
|
def self.after_suite
|
58
|
if respond_to?(:extension_class)
|
59
|
self.support.destroy_repo(clone_name)
|
60
|
self.support.destroy_repo
|
61
|
end
|
62
|
end
|
63
|
|
64
|
def content_ids(repo)
|
65
|
groups = units(repo)
|
66
|
groups.map { |i| i['metadata']['id'] }
|
67
|
end
|
68
|
|
69
|
def units(repo)
|
70
|
TestRuncible.server.extensions.repository.unit_search(repo,
|
71
|
:type_ids => [self.class.extension_class.content_type])
|
72
|
end
|
73
|
|
74
|
def unit_ids(repo)
|
75
|
units(repo).map { |i| i['unit_id'] }
|
76
|
end
|
77
|
end
|
78
|
end
|