MCPcopy Index your code
hub / github.com/cli/cli / Test_getBody

Function Test_getBody

pkg/cmd/secret/set/set_test.go:805–847  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

803}
804
805func Test_getBody(t *testing.T) {
806 tests := []struct {
807 name string
808 bodyArg string
809 want string
810 stdin string
811 }{
812 {
813 name: "literal value",
814 bodyArg: "a secret",
815 want: "a secret",
816 },
817 {
818 name: "from stdin",
819 want: "a secret",
820 stdin: "a secret",
821 },
822 {
823 name: "from stdin with trailing newline character",
824 want: "a secret",
825 stdin: "a secret\n",
826 },
827 }
828
829 for _, tt := range tests {
830 t.Run(tt.name, func(t *testing.T) {
831 ios, stdin, _, _ := iostreams.Test()
832
833 ios.SetStdinTTY(false)
834
835 _, err := stdin.WriteString(tt.stdin)
836 assert.NoError(t, err)
837
838 body, err := getBody(&SetOptions{
839 Body: tt.bodyArg,
840 IO: ios,
841 })
842 assert.NoError(t, err)
843
844 assert.Equal(t, tt.want, string(body))
845 })
846 }
847}
848
849func Test_getBodyPrompt(t *testing.T) {
850 ios, _, _, _ := iostreams.Test()

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
SetStdinTTYMethod · 0.80
EqualMethod · 0.80
getBodyFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected