(t *testing.T)
| 803 | } |
| 804 | |
| 805 | func 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 | |
| 849 | func Test_getBodyPrompt(t *testing.T) { |
| 850 | ios, _, _, _ := iostreams.Test() |
nothing calls this directly
no test coverage detected