mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-06-29 20:58:29 +00:00
xattr: simple wrapper for syscalls
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
ec1977017d
commit
2d3aea8623
3 changed files with 86 additions and 0 deletions
38
xattr/xattr_test.go
Normal file
38
xattr/xattr_test.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package xattr
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestXattr(t *testing.T) {
|
||||
fh, err := ioutil.TempFile(".", "xattr.")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(fh.Name())
|
||||
if err := fh.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := []byte("1234")
|
||||
if err := Set(fh.Name(), "user.testing", expected); err != nil {
|
||||
t.Fatal(fh.Name(), err)
|
||||
}
|
||||
l, err := List(fh.Name())
|
||||
if err != nil {
|
||||
t.Error(fh.Name(), err)
|
||||
}
|
||||
if !(len(l) > 0) {
|
||||
t.Errorf("%q: expected a list of at least 1; got %d", len(l))
|
||||
}
|
||||
got, err := Get(fh.Name(), "user.testing")
|
||||
if err != nil {
|
||||
t.Fatal(fh.Name(), err)
|
||||
}
|
||||
if !bytes.Equal(got, expected) {
|
||||
t.Errorf("%q: expected %q; got %q", fh.Name(), expected, got)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue