summaryrefslogtreecommitdiffstats
path: root/go-selinux/label/label_test.go
blob: fb172f3ff23a58c532fdcec1a78cbc52e1aea9dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)
	}
}