diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-07 13:33:18 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-07 13:33:18 +0900 |
| commit | 0fb9e401912f89d25ff96b0dd36aabf43b4fab8f (patch) | |
| tree | 9f64f1055b70ec9bef09b7e0c004f76f9e416981 /helper/pipe_test.go | |
| parent | 9647eb6a6b5607e9aac1e2c113e80f2e966ec0ac (diff) | |
helper/args: MustNewCheckedArgs for cleaner hardcoded args
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'helper/pipe_test.go')
| -rw-r--r-- | helper/pipe_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/helper/pipe_test.go b/helper/pipe_test.go new file mode 100644 index 00000000..e9c8d06b --- /dev/null +++ b/helper/pipe_test.go @@ -0,0 +1,42 @@ +package helper + +import ( + "testing" +) + +func Test_pipes_pipe_mustClosePipes(t *testing.T) { + p := new(pipes) + + t.Run("pipe without args", func(t *testing.T) { + defer func() { + wantPanic := "attempted to pipe without args" + if r := recover(); r != wantPanic { + t.Errorf("pipe() panic = %v, wantPanic %v", + r, wantPanic) + } + }() + _ = p.pipe() + }) + + p.args = MustNewCheckedArgs(make([]string, 0)) + t.Run("obtain pipes", func(t *testing.T) { + if err := p.pipe(); err != nil { + t.Errorf("pipe() error = %v", + err) + return + } + }) + + t.Run("pipe twice", func(t *testing.T) { + defer func() { + wantPanic := "attempted to pipe twice" + if r := recover(); r != wantPanic { + t.Errorf("pipe() panic = %v, wantPanic %v", + r, wantPanic) + } + }() + _ = p.pipe() + }) + + p.mustClosePipes() +} |
