diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-13 01:15:19 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-13 01:17:47 +0900 |
| commit | 4e7aab07d5b175345fdf3ea08868dab1e6d90126 (patch) | |
| tree | a625cca0e8cdf576313fe2d9ab07a22d1839ee7c /internal/system/acl/libacl-helper_test.go | |
| parent | 15a66a2b314e7a674c9445e25ffb2451ec73b55e (diff) | |
internal/system: relocate from system
These packages are highly specific to hakurei and are difficult to use safely from other pieces of code.
Their exported symbols are made available until v0.4.0 where they will be removed for #24.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/system/acl/libacl-helper_test.go')
| -rw-r--r-- | internal/system/acl/libacl-helper_test.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/internal/system/acl/libacl-helper_test.go b/internal/system/acl/libacl-helper_test.go new file mode 100644 index 00000000..13d23a3c --- /dev/null +++ b/internal/system/acl/libacl-helper_test.go @@ -0,0 +1,60 @@ +package acl + +import ( + "os" + "reflect" + "syscall" + "testing" + + "hakurei.app/container" +) + +func TestNewAclPathError(t *testing.T) { + testCases := []struct { + name string + path string + r int + err error + want error + }{ + {"nil", container.Nonexistent, 0, syscall.ENOTRECOVERABLE, nil}, + + {"acl_get_file", container.Nonexistent, -1, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_get_file", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_get_tag_type", container.Nonexistent, -2, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_get_tag_type", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_get_qualifier", container.Nonexistent, -3, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_get_qualifier", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_delete_entry", container.Nonexistent, -4, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_delete_entry", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_create_entry", container.Nonexistent, -5, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_create_entry", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_get_permset", container.Nonexistent, -6, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_get_permset", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_add_perm", container.Nonexistent, -7, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_add_perm", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_set_tag_type", container.Nonexistent, -8, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_set_tag_type", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_set_qualifier", container.Nonexistent, -9, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_set_qualifier", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_calc_mask", container.Nonexistent, -10, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_calc_mask", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_valid", container.Nonexistent, -11, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_valid", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"acl_set_file", container.Nonexistent, -12, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "acl_set_file", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + + {"acl", container.Nonexistent, -13, syscall.ENOTRECOVERABLE, + &os.PathError{Op: "setfacl", Path: container.Nonexistent, Err: syscall.ENOTRECOVERABLE}}, + {"invalid", container.Nonexistent, -0xdead, nil, + &os.PathError{Op: "setfacl", Path: container.Nonexistent}}, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + err := newAclPathError(tc.path, tc.r, tc.err) + if !reflect.DeepEqual(err, tc.want) { + t.Errorf("newAclPathError: %v, want %v", err, tc.want) + } + }) + } +} |
