@@ -1026,6 +1026,7 @@ def set(_context, changes) end
10261026 let ( :definition ) do
10271027 {
10281028 name : 'composite' ,
1029+ desc : 'some desc' ,
10291030 title_patterns : [
10301031 {
10311032 pattern : %r{^(?<package>.*[^/])/(?<manager>.*)$} ,
@@ -1039,13 +1040,16 @@ def set(_context, changes) end
10391040 attributes : {
10401041 ensure : {
10411042 type : 'Enum[present, absent]' ,
1043+ desc : '' ,
10421044 } ,
10431045 package : {
10441046 type : 'String' ,
1047+ desc : '' ,
10451048 behavior : :namevar ,
10461049 } ,
10471050 manager : {
10481051 type : 'String' ,
1052+ desc : '' ,
10491053 behavior : :namevar ,
10501054 } ,
10511055 } ,
@@ -1123,6 +1127,120 @@ def set(_context, _changes); end
11231127 type_class . new ( title : 'php/yum' , ensure : :absent ) . flush
11241128 end
11251129 end
1130+
1131+ context 'when no title is returned by get' do
1132+ let ( :provider_class ) do
1133+ Class . new do
1134+ def get ( _context )
1135+ [ { package : 'php' , manager : 'yum' , ensure : 'present' } ]
1136+ end
1137+
1138+ def set ( _context , _changes ) ; end
1139+ end
1140+ end
1141+ let ( :type ) { type_class . new ( title : 'mytitle' , package : 'php' , manager : 'yum' ) }
1142+
1143+ context 'when Puppet strict setting is :off' do
1144+ let ( :strict_level ) { :off }
1145+
1146+ it 'instances will not log a warning' do
1147+ expect ( Puppet ) . not_to receive ( :warning )
1148+ type_class . instances
1149+ end
1150+
1151+ it 'refresh_current_state will not log a warning' do
1152+ expect ( Puppet ) . not_to receive ( :warning )
1153+ type . refresh_current_state
1154+ end
1155+ end
1156+
1157+ context 'when Puppet strict setting is :error' do
1158+ let ( :strict_level ) { :error }
1159+
1160+ it 'instances will throw an exception' do
1161+ expect {
1162+ type_class . instances
1163+ } . to raise_error ( Puppet ::DevError , %r{has not provided a title attribute} )
1164+ end
1165+
1166+ it 'refresh_current_state will throw an exception' do
1167+ expect {
1168+ type . refresh_current_state
1169+ } . to raise_error ( Puppet ::DevError , %r{has not provided a title attribute} )
1170+ end
1171+ end
1172+
1173+ context 'when Puppet strict setting is :warning' do
1174+ let ( :strict_level ) { :warning }
1175+
1176+ it 'instances will not log a warning' do
1177+ expect ( Puppet ) . to receive ( :warning ) . with ( %r{has not provided a title attribute} )
1178+ type_class . instances
1179+ end
1180+
1181+ it 'refresh_current_state will not log a warning' do
1182+ expect ( Puppet ) . to receive ( :warning ) . with ( %r{has not provided a title attribute} )
1183+ type . refresh_current_state
1184+ end
1185+ end
1186+ end
1187+
1188+ context 'when the title does not match a title pattern' do
1189+ let ( :provider_class ) do
1190+ Class . new do
1191+ def get ( _context )
1192+ [ { title : 'Nomatch' , package : 'php' , manager : 'yum' , ensure : 'present' } ]
1193+ end
1194+
1195+ def set ( _context , _changes ) ; end
1196+ end
1197+ end
1198+ let ( :type ) { type_class . new ( title : 'mytitle' , package : 'php' , manager : 'yum' ) }
1199+
1200+ context 'when Puppet strict setting is :off' do
1201+ let ( :strict_level ) { :off }
1202+
1203+ it 'instances will not log a warning' do
1204+ expect ( Puppet ) . not_to receive ( :warning )
1205+ type_class . instances
1206+ end
1207+
1208+ it 'refresh_current_state will not log a warning' do
1209+ expect ( Puppet ) . not_to receive ( :warning )
1210+ type . refresh_current_state
1211+ end
1212+ end
1213+
1214+ context 'when Puppet strict setting is :error' do
1215+ let ( :strict_level ) { :error }
1216+
1217+ it 'instances will throw an exception' do
1218+ expect {
1219+ type_class . instances
1220+ } . to raise_error ( Puppet ::DevError , %r{has provided a title attribute which does not match} )
1221+ end
1222+
1223+ it 'refresh_current_state will throw an exception' do
1224+ expect {
1225+ type . refresh_current_state
1226+ } . to raise_error ( Puppet ::DevError , %r{has provided a title attribute which does not match} )
1227+ end
1228+ end
1229+
1230+ context 'when Puppet strict setting is :warning' do
1231+ let ( :strict_level ) { :warning }
1232+
1233+ it 'instances will not log a warning' do
1234+ expect ( Puppet ) . to receive ( :warning ) . with ( %r{has provided a title attribute which does not match} )
1235+ type_class . instances
1236+ end
1237+
1238+ it 'refresh_current_state will not log a warning' do
1239+ expect ( Puppet ) . to receive ( :warning ) . with ( %r{has provided a title attribute which does not match} )
1240+ type . refresh_current_state
1241+ end
1242+ end
1243+ end
11261244 end
11271245 end
11281246
0 commit comments