File: label_test.go

package info (click to toggle)
golang-github-opencontainers-selinux 1.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 280 kB
  • sloc: makefile: 31
file content (35 lines) | stat: -rw-r--r-- 1,100 bytes parent folder | download | duplicates (3)
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)
	}
}