...

Source file src/github.com/opencontainers/selinux/go-selinux/label/label_test.go

Documentation: github.com/opencontainers/selinux/go-selinux/label

     1  package label
     2  
     3  import "testing"
     4  
     5  func TestFormatMountLabel(t *testing.T) {
     6  	expected := `context="foobar"`
     7  	if test := FormatMountLabel("", "foobar"); test != expected {
     8  		t.Fatalf("Format failed. Expected %s, got %s", expected, test)
     9  	}
    10  
    11  	expected = `src,context="foobar"`
    12  	if test := FormatMountLabel("src", "foobar"); test != expected {
    13  		t.Fatalf("Format failed. Expected %s, got %s", expected, test)
    14  	}
    15  
    16  	expected = `src`
    17  	if test := FormatMountLabel("src", ""); test != expected {
    18  		t.Fatalf("Format failed. Expected %s, got %s", expected, test)
    19  	}
    20  
    21  	expected = `fscontext="foobar"`
    22  	if test := FormatMountLabelByType("", "foobar", "fscontext"); test != expected {
    23  		t.Fatalf("Format failed. Expected %s, got %s", expected, test)
    24  	}
    25  
    26  	expected = `src,fscontext="foobar"`
    27  	if test := FormatMountLabelByType("src", "foobar", "fscontext"); test != expected {
    28  		t.Fatalf("Format failed. Expected %s, got %s", expected, test)
    29  	}
    30  
    31  	expected = `src`
    32  	if test := FormatMountLabelByType("src", "", "rootcontext"); test != expected {
    33  		t.Fatalf("Format failed. Expected %s, got %s", expected, test)
    34  	}
    35  }
    36  

View as plain text