|
1 | 1 | package pipelines |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "bytes" |
5 | 4 | "context" |
6 | 5 | "testing" |
7 | 6 | "time" |
8 | 7 |
|
9 | 8 | "github.com/databricks/cli/libs/cmdio" |
10 | | - "github.com/databricks/cli/libs/flags" |
11 | 9 | "github.com/databricks/databricks-sdk-go/service/pipelines" |
12 | 10 | "github.com/stretchr/testify/assert" |
13 | 11 | ) |
@@ -146,15 +144,11 @@ Pipeline configurations for this update: |
146 | 144 |
|
147 | 145 | for _, tt := range tests { |
148 | 146 | t.Run(tt.name, func(t *testing.T) { |
149 | | - var buf bytes.Buffer |
150 | | - |
151 | | - ctx := context.Background() |
152 | | - cmdIO := cmdio.NewIO(ctx, flags.OutputText, nil, &buf, &buf, "", "") |
153 | | - ctx = cmdio.InContext(ctx, cmdIO) |
| 147 | + ctx, stdout := cmdio.NewTestContextWithStdout(context.Background()) |
154 | 148 |
|
155 | 149 | err := displayPipelineUpdate(ctx, tt.update, tt.pipelineID, tt.events) |
156 | 150 | assert.NoError(t, err) |
157 | | - assert.Equal(t, tt.expected, buf.String()) |
| 151 | + assert.Equal(t, tt.expected, stdout.String()) |
158 | 152 | }) |
159 | 153 | } |
160 | 154 | } |
@@ -376,15 +370,11 @@ RUNNING 750ms |
376 | 370 |
|
377 | 371 | for _, tt := range tests { |
378 | 372 | t.Run(tt.name, func(t *testing.T) { |
379 | | - var buf bytes.Buffer |
380 | | - |
381 | | - ctx := context.Background() |
382 | | - cmdIO := cmdio.NewIO(ctx, flags.OutputText, nil, &buf, &buf, "", "") |
383 | | - ctx = cmdio.InContext(ctx, cmdIO) |
| 373 | + ctx, stdout := cmdio.NewTestContextWithStdout(context.Background()) |
384 | 374 |
|
385 | 375 | err := displayProgressEventsDurations(ctx, tt.events) |
386 | 376 | assert.NoError(t, err) |
387 | | - assert.Equal(t, tt.expected, buf.String()) |
| 377 | + assert.Equal(t, tt.expected, stdout.String()) |
388 | 378 | }) |
389 | 379 | } |
390 | 380 | } |
0 commit comments