@@ -802,10 +802,12 @@ def check_filtered_instances(*instances)
802802 expect ( instance . tags ) . to contain_exactly ( 'foo' , 'bar' , 'baz' )
803803 expect ( instance . credentials ) . to match ( { 'foo' => 'bar' , 'baz' => 'qux' } )
804804 expect ( instance . space ) . to eq ( space )
805- expect ( instance . annotations [ 0 ] . key_name ) . to eq ( 'foo' )
806- expect ( instance . annotations [ 0 ] . value ) . to eq ( 'bar' )
807- expect ( instance . labels [ 0 ] . key_name ) . to eq ( 'baz' )
808- expect ( instance . labels [ 0 ] . value ) . to eq ( 'qux' )
805+
806+ expect_metadata (
807+ instance ,
808+ annotations : [ { prefix : nil , key : 'foo' , value : 'bar' } ] ,
809+ labels : [ { prefix : nil , key : 'baz' , value : 'qux' } ]
810+ )
809811 end
810812
811813 context 'when the name has already been taken' do
@@ -879,10 +881,13 @@ def check_filtered_instances(*instances)
879881 expect ( instance . tags ) . to contain_exactly ( 'foo' , 'bar' , 'baz' )
880882 expect ( instance . space ) . to eq ( space )
881883 expect ( instance . service_plan ) . to eq ( service_plan )
882- expect ( instance . annotations [ 0 ] . key_name ) . to eq ( 'foo' )
883- expect ( instance . annotations [ 0 ] . value ) . to eq ( 'bar' )
884- expect ( instance . labels [ 0 ] . key_name ) . to eq ( 'baz' )
885- expect ( instance . labels [ 0 ] . value ) . to eq ( 'qux' )
884+
885+ expect_metadata (
886+ instance ,
887+ annotations : [ { prefix : nil , key : 'foo' , value : 'bar' } ] ,
888+ labels : [ { prefix : nil , key : 'baz' , value : 'qux' } ]
889+ )
890+
886891 expect ( instance . last_operation . type ) . to eq ( 'create' )
887892 expect ( instance . last_operation . state ) . to eq ( 'in progress' )
888893 end
@@ -1384,27 +1389,19 @@ def check_filtered_instances(*instances)
13841389 service_instance . reload
13851390 expect ( service_instance . reload . tags ) . to eq ( %w( baz quz ) )
13861391
1387- expect ( service_instance . annotations ) . to have ( 3 ) . entries
1388- expect ( service_instance . annotations [ 0 ] . key_prefix ) . to eq ( 'pre.fix' )
1389- expect ( service_instance . annotations [ 0 ] . key_name ) . to eq ( 'fox' )
1390- expect ( service_instance . annotations [ 0 ] . value ) . to eq ( 'bushy' )
1391- expect ( service_instance . annotations [ 1 ] . key_prefix ) . to be_nil
1392- expect ( service_instance . annotations [ 1 ] . key_name ) . to eq ( 'potato' )
1393- expect ( service_instance . annotations [ 1 ] . value ) . to eq ( 'idaho' )
1394- expect ( service_instance . annotations [ 2 ] . key_prefix ) . to be_nil
1395- expect ( service_instance . annotations [ 2 ] . key_name ) . to eq ( 'style' )
1396- expect ( service_instance . annotations [ 2 ] . value ) . to eq ( 'mashed' )
1397-
1398- expect ( service_instance . labels ) . to have ( 3 ) . entries
1399- expect ( service_instance . labels [ 0 ] . key_prefix ) . to eq ( 'pre.fix' )
1400- expect ( service_instance . labels [ 0 ] . key_name ) . to eq ( 'tail' )
1401- expect ( service_instance . labels [ 0 ] . value ) . to eq ( 'fluffy' )
1402- expect ( service_instance . labels [ 1 ] . key_prefix ) . to be_nil
1403- expect ( service_instance . labels [ 1 ] . key_name ) . to eq ( 'potato' )
1404- expect ( service_instance . labels [ 1 ] . value ) . to eq ( 'yam' )
1405- expect ( service_instance . labels [ 2 ] . key_prefix ) . to be_nil
1406- expect ( service_instance . labels [ 2 ] . key_name ) . to eq ( 'style' )
1407- expect ( service_instance . labels [ 2 ] . value ) . to eq ( 'baked' )
1392+ expect_metadata (
1393+ service_instance ,
1394+ annotations : [
1395+ { prefix : 'pre.fix' , key : 'fox' , value : 'bushy' } ,
1396+ { prefix : nil , key : 'potato' , value : 'idaho' } ,
1397+ { prefix : nil , key : 'style' , value : 'mashed' } ,
1398+ ] ,
1399+ labels : [
1400+ { prefix : 'pre.fix' , key : 'tail' , value : 'fluffy' } ,
1401+ { prefix : nil , key : 'potato' , value : 'yam' } ,
1402+ { prefix : nil , key : 'style' , value : 'baked' }
1403+ ]
1404+ )
14081405
14091406 expect ( service_instance . last_operation . type ) . to eq ( 'update' )
14101407 expect ( service_instance . last_operation . state ) . to eq ( 'succeeded' )
@@ -1488,21 +1485,17 @@ def check_filtered_instances(*instances)
14881485 service_instance . reload
14891486 expect ( service_instance . reload . tags ) . to eq ( %w( foo bar ) )
14901487
1491- expect ( service_instance . annotations ) . to have ( 2 ) . entries
1492- expect ( service_instance . annotations [ 0 ] . key_prefix ) . to eq ( 'pre.fix' )
1493- expect ( service_instance . annotations [ 0 ] . key_name ) . to eq ( 'to_delete' )
1494- expect ( service_instance . annotations [ 0 ] . value ) . to eq ( 'value' )
1495- expect ( service_instance . annotations [ 1 ] . key_prefix ) . to eq ( 'pre.fix' )
1496- expect ( service_instance . annotations [ 1 ] . key_name ) . to eq ( 'fox' )
1497- expect ( service_instance . annotations [ 1 ] . value ) . to eq ( 'bushy' )
1498-
1499- expect ( service_instance . labels ) . to have ( 2 ) . entries
1500- expect ( service_instance . labels [ 0 ] . key_prefix ) . to eq ( 'pre.fix' )
1501- expect ( service_instance . labels [ 0 ] . key_name ) . to eq ( 'to_delete' )
1502- expect ( service_instance . labels [ 0 ] . value ) . to eq ( 'value' )
1503- expect ( service_instance . labels [ 1 ] . key_prefix ) . to eq ( 'pre.fix' )
1504- expect ( service_instance . labels [ 1 ] . key_name ) . to eq ( 'tail' )
1505- expect ( service_instance . labels [ 1 ] . value ) . to eq ( 'fluffy' )
1488+ expect_metadata (
1489+ service_instance ,
1490+ annotations : [
1491+ { prefix : 'pre.fix' , key : 'to_delete' , value : 'value' } ,
1492+ { prefix : 'pre.fix' , key : 'fox' , value : 'bushy' } ,
1493+ ] ,
1494+ labels : [
1495+ { prefix : 'pre.fix' , key : 'to_delete' , value : 'value' } ,
1496+ { prefix : 'pre.fix' , key : 'tail' , value : 'fluffy' }
1497+ ]
1498+ )
15061499 end
15071500
15081501 describe 'the pollable job' do
@@ -1921,6 +1914,27 @@ def create_user_provided_json(instance, labels: {}, annotations: {})
19211914 }
19221915 end
19231916
1917+ def expect_metadata ( instance , annotations : [ ] , labels : [ ] )
1918+ a = instance . annotations . map do |e |
1919+ {
1920+ prefix : e . key_prefix ,
1921+ key : e . key_name ,
1922+ value : e . value ,
1923+ }
1924+ end
1925+
1926+ l = instance . labels . map do |e |
1927+ {
1928+ prefix : e . key_prefix ,
1929+ key : e . key_name ,
1930+ value : e . value ,
1931+ }
1932+ end
1933+
1934+ expect ( a ) . to match_array ( annotations )
1935+ expect ( l ) . to match_array ( labels )
1936+ end
1937+
19241938 describe 'unrefactored' do
19251939 let ( :user_email ) { 'user@email.example.com' }
19261940 let ( :user_name ) { 'username' }
0 commit comments