summaryrefslogtreecommitdiffstats
path: root/go-selinux/label/label_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'go-selinux/label/label_test.go')
-rw-r--r--go-selinux/label/label_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/go-selinux/label/label_test.go b/go-selinux/label/label_test.go
new file mode 100644
index 0000000..fb172f3
--- /dev/null
+++ b/go-selinux/label/label_test.go
@@ -0,0 +1,35 @@
+package label
+
+import "testing"
+
+func TestFormatMountLabel(t *testing.T) {
+ expected := `context="foobar"`
+ if test := FormatMountLabel("", "foobar"); test != expected {
+ t.Fatalf("Format failed. Expected %s, got %s", expected, test)
+ }
+
+ expected = `src,context="foobar"`
+ if test := FormatMountLabel("src", "foobar"); test != expected {
+ t.Fatalf("Format failed. Expected %s, got %s", expected, test)
+ }
+
+ expected = `src`
+ if test := FormatMountLabel("src", ""); test != expected {
+ t.Fatalf("Format failed. Expected %s, got %s", expected, test)
+ }
+
+ expected = `fscontext="foobar"`
+ if test := FormatMountLabelByType("", "foobar", "fscontext"); test != expected {
+ t.Fatalf("Format failed. Expected %s, got %s", expected, test)
+ }
+
+ expected = `src,fscontext="foobar"`
+ if test := FormatMountLabelByType("src", "foobar", "fscontext"); test != expected {
+ t.Fatalf("Format failed. Expected %s, got %s", expected, test)
+ }
+
+ expected = `src`
+ if test := FormatMountLabelByType("src", "", "rootcontext"); test != expected {
+ t.Fatalf("Format failed. Expected %s, got %s", expected, test)
+ }
+}