@@ -372,6 +372,43 @@ func TestProgress_RenderNothing(t *testing.T) {
372372 assert .Empty (t , renderOutput .String ())
373373}
374374
375+ func TestProgress_RenderSomeTrackers_AndRemove (t * testing.T ) {
376+ renderOutput := outputWriter {}
377+
378+ pw := generateWriter ()
379+ pw .SetOutputWriter (& renderOutput )
380+ pw .SetTrackerPosition (PositionLeft )
381+ go trackSomething (pw , & Tracker {Message : "Calculating Total # 1" , Total : 1000 , Units : UnitsDefault , RemoveOnCompletion : true })
382+ go trackSomething (pw , & Tracker {Message : "Downloading File # 2" , Total : 1000 , Units : UnitsBytes , RemoveOnCompletion : true })
383+ go trackSomething (pw , & Tracker {Message : "Transferring Amount # 3" , Total : 1000 , Units : UnitsCurrencyDollar , RemoveOnCompletion : true })
384+ renderAndWait (pw , false )
385+ out := renderOutput .String ()
386+
387+ expectedOutPatterns := []* regexp.Regexp {
388+ regexp .MustCompile (`\d+\.\d+% \[[#.]{23}] \[\d+ in [\d.]+ms] \.\.\. Calculating Total # 1` ),
389+ regexp .MustCompile (`\d+\.\d+% \[[#.]{23}] \[\d+B in [\d.]+ms] \.\.\. Downloading File # 2` ),
390+ regexp .MustCompile (`\d+\.\d+% \[[#.]{23}] \[\$\d+ in [\d.]+ms] \.\.\. Transferring Amount # 3` ),
391+ }
392+ for _ , expectedOutPattern := range expectedOutPatterns {
393+ if ! expectedOutPattern .MatchString (out ) {
394+ assert .Fail (t , "Failed to find a pattern in the Output." , expectedOutPattern .String ())
395+ }
396+ }
397+
398+ unexpectedOutPatterns := []* regexp.Regexp {
399+ regexp .MustCompile (`Calculating Total # 1 \.\.\. done! \[\d+\.\d+K in [\d.]+ms]` ),
400+ regexp .MustCompile (`Downloading File # 2 \.\.\. done! \[\d+\.\d+KB in [\d.]+ms]` ),
401+ regexp .MustCompile (`Transferring Amount # 3 \.\.\. done! \[\$\d+\.\d+K in [\d.]+ms]` ),
402+ }
403+ for _ , unexpectedOutPattern := range unexpectedOutPatterns {
404+ if unexpectedOutPattern .MatchString (out ) {
405+ assert .Fail (t , "Found a pattern in the Output which was not expected." , unexpectedOutPattern .String ())
406+ }
407+ }
408+
409+ showOutputOnFailure (t , out )
410+ }
411+
375412func TestProgress_RenderSomeTrackers_OnLeftSide (t * testing.T ) {
376413 renderOutput := outputWriter {}
377414
0 commit comments