File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Copyright (c) Microsoft Corporation.
2+ // Licensed under the MIT License.
3+
4+ package azldev
5+
6+ import (
7+ "io"
8+ "os"
9+ "testing"
10+
11+ "github.com/stretchr/testify/assert"
12+ "github.com/stretchr/testify/require"
13+ )
14+
15+ func captureStderr (t * testing.T , action func ()) string {
16+ t .Helper ()
17+
18+ originalStderr := os .Stderr
19+ reader , writer , err := os .Pipe ()
20+ require .NoError (t , err )
21+
22+ os .Stderr = writer
23+
24+ action ()
25+
26+ require .NoError (t , writer .Close ())
27+ os .Stderr = originalStderr
28+
29+ output , err := io .ReadAll (reader )
30+ require .NoError (t , err )
31+ require .NoError (t , reader .Close ())
32+
33+ return string (output )
34+ }
35+
36+ func TestEvent_QuietModeSkipsLongRunningAndProgressRendering (t * testing.T ) {
37+ e := & event {
38+ quiet : true ,
39+ }
40+
41+ stderrOutput := captureStderr (t , func () {
42+ e .SetLongRunning ("working" )
43+ e .SetProgress (1 , 10 )
44+ })
45+
46+ assert .Empty (t , stderrOutput )
47+ assert .Nil (t , e .spinner )
48+ assert .False (t , e .initializedProgressBar )
49+ assert .Zero (t , e .lastReportedCompletionRatio )
50+ }
You can’t perform that action at this time.
0 commit comments