@@ -282,3 +282,49 @@ func TestGenerateSNSJSON(t *testing.T) {
282282 })
283283 }
284284}
285+
286+ func TestGenerateQueueURIJSON (t * testing.T ) {
287+ testCases := map [string ]struct {
288+ in []* TopicSubscription
289+ wanted string
290+ wantedSubstring string
291+ wantedSubstring2 string
292+ }{
293+ "JSON should render correctly" : {
294+ in : []* TopicSubscription {
295+ {
296+ Name : aws .String ("tests" ),
297+ Service : aws .String ("bestsvc" ),
298+ Queue : & SQSQueue {
299+ Delay : aws .Int64 (5 ),
300+ },
301+ },
302+ },
303+ wantedSubstring : `"eventsQueue":"${mainURL}"` ,
304+ wantedSubstring2 : `"bestsvcTestsEventsQueue":"${bestsvctestsURL}"` ,
305+ },
306+ "Topics with no names show empty but main queue still populates" : {
307+ in : []* TopicSubscription {
308+ {
309+ Service : aws .String ("bestSvc" ),
310+ },
311+ },
312+ wanted : `{"eventsQueue":"${mainURL}"}` ,
313+ },
314+ "nil list of arguments should render with main queue" : {
315+ in : []* TopicSubscription {},
316+ wanted : `{"eventsQueue":"${mainURL}"}` ,
317+ },
318+ }
319+
320+ for name , tc := range testCases {
321+ t .Run (name , func (t * testing.T ) {
322+ if tc .wanted != "" {
323+ require .Equal (t , generateQueueURIJSON (tc .in ), tc .wanted )
324+ } else {
325+ require .Contains (t , generateQueueURIJSON (tc .in ), tc .wantedSubstring )
326+ require .Contains (t , generateQueueURIJSON (tc .in ), tc .wantedSubstring2 )
327+ }
328+ })
329+ }
330+ }
0 commit comments