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/helper_test.go | |
| parent | 9647eb6a6b5607e9aac1e2c113e80f2e966ec0ac (diff) | |
helper/args: MustNewCheckedArgs for cleaner hardcoded args
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'helper/helper_test.go')
| -rw-r--r-- | helper/helper_test.go | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/helper/helper_test.go b/helper/helper_test.go index 835f3585..0bbc5695 100644 --- a/helper/helper_test.go +++ b/helper/helper_test.go @@ -6,7 +6,6 @@ import ( "os" "strconv" "strings" - "sync" "testing" "time" @@ -23,20 +22,9 @@ var ( "--talk=org.freedesktop.UPower", } - wantPayload string - argsWt io.WriterTo - argsOnce sync.Once -) - -func prepareArgs() { wantPayload = strings.Join(want, "\x00") + "\x00" - - if a, err := helper.NewCheckedArgs(want); err != nil { - panic(err.Error()) - } else { - argsWt = a - } -} + argsWt = helper.MustNewCheckedArgs(want) +) func argF(argsFD int, _ int) []string { return []string{"--args", strconv.Itoa(argsFD)} @@ -48,7 +36,6 @@ func argFStatus(argsFD int, statFD int) []string { func TestHelper_StartNotify_Close_Wait(t *testing.T) { helper.InternalReplaceExecCommand(t) - argsOnce.Do(prepareArgs) t.Run("start non-existent helper path", func(t *testing.T) { h := helper.New(argsWt, "/nonexistent", argF) @@ -143,7 +130,6 @@ func TestHelper_StartNotify_Close_Wait(t *testing.T) { } func TestHelper_Start_Close_Wait(t *testing.T) { helper.InternalReplaceExecCommand(t) - argsOnce.Do(prepareArgs) var wt io.WriterTo if a, err := helper.NewCheckedArgs(want); err != nil { |
