Skip to content

Commit bbb2861

Browse files
committed
use ptytest instead of a strings.Builder to assert cli output
1 parent ba9c22d commit bbb2861

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

cli/templatepush_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,9 @@ func TestTemplatePush(t *testing.T) {
536536

537537
templateName := strings.ReplaceAll(testutil.GetRandomName(t), "_", "-")
538538

539-
var output strings.Builder
540539
inv, root := clitest.New(t, "templates", "push", templateName, "-d", tempDir, "--yes")
541-
inv.Stdout = &output
542-
inv.Stderr = &output
543540
clitest.SetupConfig(t, templateAdmin, root)
541+
pty := ptytest.New(t).Attach(inv)
544542

545543
ctx := testutil.Context(t, testutil.WaitShort)
546544
now := dbtime.Now()
@@ -563,12 +561,13 @@ func TestTemplatePush(t *testing.T) {
563561
}
564562
return assert.EqualValues(t, wantTags, jobs[0].Tags)
565563
}, testutil.WaitShort, testutil.IntervalFast)
566-
cancel()
567-
<-done
568564

569565
if tt.expectOutput != "" {
570-
require.Contains(t, output.String(), tt.expectOutput)
566+
pty.ExpectMatch(tt.expectOutput)
571567
}
568+
569+
cancel()
570+
<-done
572571
})
573572
}
574573
})

0 commit comments

Comments
 (0)