From 4d3e26e92780daaccc0f586ff2ca0aa9e6f08097 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Thu, 10 Sep 2020 13:19:43 -0500 Subject: [PATCH] prompts disabled test for auth refresh the behavior for nontty vs. prompts disabled is pretty different so i opted for a new test, here --- pkg/cmd/auth/refresh/refresh_test.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/auth/refresh/refresh_test.go b/pkg/cmd/auth/refresh/refresh_test.go index cba3c107a..46db2af52 100644 --- a/pkg/cmd/auth/refresh/refresh_test.go +++ b/pkg/cmd/auth/refresh/refresh_test.go @@ -18,11 +18,12 @@ import ( func Test_NewCmdRefresh(t *testing.T) { tests := []struct { - name string - cli string - wants RefreshOptions - wantsErr bool - tty bool + name string + cli string + wants RefreshOptions + wantsErr bool + tty bool + neverPrompt bool }{ { name: "tty no arguments", @@ -48,6 +49,22 @@ func Test_NewCmdRefresh(t *testing.T) { Hostname: "aline.cedrac", }, }, + { + name: "prompts disabled, no args", + tty: true, + cli: "", + neverPrompt: true, + wantsErr: true, + }, + { + name: "prompts disabled, hostname", + tty: true, + cli: "-h aline.cedrac", + neverPrompt: true, + wants: RefreshOptions{ + Hostname: "aline.cedrac", + }, + }, { name: "tty one scope", tty: true, @@ -74,6 +91,7 @@ func Test_NewCmdRefresh(t *testing.T) { } io.SetStdinTTY(tt.tty) io.SetStdoutTTY(tt.tty) + io.SetNeverPrompt(tt.neverPrompt) argv, err := shlex.Split(tt.cli) assert.NoError(t, err)