aboutsummaryrefslogtreecommitdiffhomepage
path: root/system/op_internal_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-30 22:49:12 +0900
committerOphestra <cat@gensokyo.uk>2025-08-30 22:49:12 +0900
commitf5abce9df5727904a1daa246025a87c4bfe62553 (patch)
tree7e8c29b83e97532954dee8adb5f86962eaebca34 /system/op_internal_test.go
parentddb003e39b64c2417cabc291383d99b4ad64ac8f (diff)
system: wrap op errors
This passes more information allowing for better error handling. This eliminates generic WrapErr from system. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system/op_internal_test.go')
-rw-r--r--system/op_internal_test.go68
1 files changed, 0 insertions, 68 deletions
diff --git a/system/op_internal_test.go b/system/op_internal_test.go
deleted file mode 100644
index 4d43309e..00000000
--- a/system/op_internal_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package system
-
-import "testing"
-
-type tcOp struct {
- et Enablement
- path string
-}
-
-// test an instance of the Op interface
-func (ptc tcOp) test(t *testing.T, gotOps []Op, wantOps []Op, fn string) {
- if len(gotOps) != len(wantOps) {
- t.Errorf("%s: inserted %v Ops, want %v", fn,
- len(gotOps), len(wantOps))
- return
- }
-
- t.Run("path", func(t *testing.T) {
- if len(gotOps) > 0 {
- if got := gotOps[0].Path(); got != ptc.path {
- t.Errorf("Path() = %q, want %q",
- got, ptc.path)
- return
- }
- }
- })
-
- for i := range gotOps {
- o := gotOps[i]
-
- t.Run("is", func(t *testing.T) {
- if !o.Is(o) {
- t.Errorf("Is returned false on self")
- return
- }
- if !o.Is(wantOps[i]) {
- t.Errorf("%s: inserted %#v, want %#v",
- fn,
- o, wantOps[i])
- return
- }
- })
-
- t.Run("criteria", func(t *testing.T) {
- testCases := []struct {
- name string
- ec *Criteria
- want bool
- }{
- {"nil", nil, ptc.et != User},
- {"self", newCriteria(ptc.et), true},
- {"all", newCriteria(EWayland | EX11 | EDBus | EPulse | User | Process), true},
- {"enablements", newCriteria(EWayland | EX11 | EDBus | EPulse), ptc.et != User && ptc.et != Process},
- }
-
- for _, tc := range testCases {
- t.Run(tc.name, func(t *testing.T) {
- if got := tc.ec.hasType(o); got != tc.want {
- t.Errorf("hasType: got %v, want %v",
- got, tc.want)
- }
- })
- }
- })
- }
-}
-
-func newCriteria(e Enablement) *Criteria { return (*Criteria)(&e) }