1
|
require 'rubygems'
|
2
|
require 'minitest/autorun'
|
3
|
|
4
|
require './test/support/repository_support'
|
5
|
require './lib/runcible/resources/event_notifier'
|
6
|
|
7
|
module Resources
|
8
|
module TestEventNotifierBase
|
9
|
def setup
|
10
|
@resource = TestRuncible.server.resources.event_notifier
|
11
|
@resource_class = Runcible::Resources::EventNotifier
|
12
|
end
|
13
|
end
|
14
|
|
15
|
class TestEventNotifier < MiniTest::Unit::TestCase
|
16
|
include TestEventNotifierBase
|
17
|
|
18
|
def setup
|
19
|
super
|
20
|
@@notifier_id = nil
|
21
|
end
|
22
|
|
23
|
def teardown
|
24
|
@resource.delete(@@notifier_id) if @@notifier_id
|
25
|
end
|
26
|
|
27
|
def test_create
|
28
|
response = @resource.create(@resource_class::NotifierTypes::REST_API, {:url => 'http://foo.com/foo/'},
|
29
|
[@resource_class::EventTypes::REPO_PUBLISH_COMPLETE])
|
30
|
@@notifier_id = response['id']
|
31
|
|
32
|
assert_equal 201, response.code
|
33
|
end
|
34
|
end
|
35
|
|
36
|
class TestEventNotifierList < MiniTest::Unit::TestCase
|
37
|
include TestEventNotifierBase
|
38
|
|
39
|
def setup
|
40
|
super
|
41
|
response = @resource.create(@resource.class::NotifierTypes::REST_API, {:url => 'http://foo.com/foo/'},
|
42
|
[@resource_class::EventTypes::REPO_PUBLISH_COMPLETE])
|
43
|
@@notifier_id = response['id']
|
44
|
end
|
45
|
|
46
|
def teardown
|
47
|
@resource.delete(@@notifier_id)
|
48
|
end
|
49
|
|
50
|
def test_list
|
51
|
response = @resource.list
|
52
|
|
53
|
assert_equal 200, response.code
|
54
|
refute_empty response
|
55
|
end
|
56
|
end
|
57
|
|
58
|
class TestEventNotifierDelete < MiniTest::Unit::TestCase
|
59
|
include TestEventNotifierBase
|
60
|
|
61
|
def setup
|
62
|
super
|
63
|
response = @resource.create(@resource.class::NotifierTypes::REST_API, {:url => 'http://foo.com/foo/'},
|
64
|
[@resource_class::EventTypes::REPO_PUBLISH_COMPLETE])
|
65
|
@@notifier_id = response['id']
|
66
|
end
|
67
|
|
68
|
def test_remove
|
69
|
response = @resource.delete(@@notifier_id)
|
70
|
|
71
|
assert_equal 200, response.code
|
72
|
end
|
73
|
end
|
74
|
end
|