@@ -23,13 +23,45 @@ module JavaBuildpack::Util
2323
2424 let ( :vcap_services ) do
2525 {
26- 'newrelic-n/a' => [
27- { 'name' => 'new-relic' }
28- ] ,
29- 'elephantsql-n/a' => [
30- { 'name' => 'db1' } ,
31- { 'name' => 'db2' }
32- ]
26+ 'newrelic-n/a' => [
27+ { 'name' => 'new-relic' }
28+ ] ,
29+ 'elephantsql-n/a' => [
30+ { 'name' => 'db1' } ,
31+ { 'name' => 'db2' }
32+ ]
33+ }
34+ end
35+
36+ let ( :vcap_services_with_name ) do
37+ {
38+ 'name-n/a' => [
39+ { 'name' => 'xnewrelicx' }
40+ ]
41+ }
42+ end
43+
44+ let ( :vcap_services_with_label ) do
45+ {
46+ 'name-n/a' => [
47+ { 'label' => 'xnewrelicx' }
48+ ]
49+ }
50+ end
51+
52+ let ( :vcap_services_with_tags ) do
53+ {
54+ 'name-n/a' => [
55+ { 'tags' => %w( y xnewrelicx z ) }
56+ ]
57+ }
58+ end
59+
60+ let ( :vcap_services_with_plan ) do
61+ {
62+ 'name-n/a' => [
63+ { 'plan' => 'xnewrelicx' }
64+ ]
3365 }
3466 end
3567
@@ -49,6 +81,22 @@ module JavaBuildpack::Util
4981 expect ( ServiceUtils . find_service ( vcap_services , /newrelic/ ) ) . to eq ( vcap_services [ 'newrelic-n/a' ] [ 0 ] )
5082 end
5183
84+ it 'should return the contents of the service if name matched' do
85+ expect ( ServiceUtils . find_service ( vcap_services_with_name , /newrelic/ ) ) . to eq ( vcap_services_with_name [ 'name-n/a' ] [ 0 ] )
86+ end
87+
88+ it 'should return the contents of the service if label matched' do
89+ expect ( ServiceUtils . find_service ( vcap_services_with_label , /newrelic/ ) ) . to eq ( vcap_services_with_label [ 'name-n/a' ] [ 0 ] )
90+ end
91+
92+ it 'should return the contents of the service if a tag matched' do
93+ expect ( ServiceUtils . find_service ( vcap_services_with_tags , /newrelic/ ) ) . to eq ( vcap_services_with_tags [ 'name-n/a' ] [ 0 ] )
94+ end
95+
96+ it 'should return nil if plan would have matched' do
97+ expect ( ServiceUtils . find_service ( vcap_services_with_plan , /newrelic/ ) ) . to be_nil
98+ end
99+
52100 end
53101
54102end
0 commit comments