From a1053c9c43262a830bbf48fdc3a5915815a999d2 Mon Sep 17 00:00:00 2001 From: Ashwin Jeyaseelan <8gitbrix@github.com> Date: Wed, 25 May 2022 18:55:36 +0000 Subject: [PATCH] Fixed error checking in test instead of incorrectly using stderr --- pkg/cmd/codespace/edit_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/cmd/codespace/edit_test.go b/pkg/cmd/codespace/edit_test.go index a974d7cdc..b35a7fb6a 100644 --- a/pkg/cmd/codespace/edit_test.go +++ b/pkg/cmd/codespace/edit_test.go @@ -2,6 +2,7 @@ package codespace import ( "context" + "fmt" "testing" "github.com/cli/cli/v2/internal/codespaces/api" @@ -18,7 +19,6 @@ func TestEdit(t *testing.T) { editErr error wantErr bool wantStdout string - wantStderr string }{ { name: "edit codespace display name", @@ -57,8 +57,8 @@ func TestEdit(t *testing.T) { displayName: "", machine: "", }, - wantStderr: "at least one property has to be edited", - wantErr: true, + editErr: fmt.Errorf("at least one property has to be edited"), + wantErr: true, }, { name: "select codespace to edit when no codespace input is given", @@ -112,7 +112,7 @@ func TestEdit(t *testing.T) { opts := tt.opts - ios, _, stdout, stderr := iostreams.Test() + ios, _, stdout, _ := iostreams.Test() ios.SetStdinTTY(true) ios.SetStdoutTTY(true) ios.SetStderrTTY(true) @@ -128,8 +128,8 @@ func TestEdit(t *testing.T) { t.Errorf("stdout = %q, want %q", out, tt.wantStdout) } - if out := stderr.String(); out != tt.wantStderr { - t.Errorf("stderr = %q, want %q", out, tt.wantStderr) + if tt.wantErr && err.Error() != tt.editErr.Error() { + t.Errorf("stderr = %v, expected error %v", err, tt.editErr) } })