mode_test.mx raw

   1  package mode
   2  
   3  import "testing"
   4  
   5  // TestIsOpenMode covers the predicate IsOpen delegates to. The test cannot set
   6  // the ACLMode global itself: package globals are immutable outside init.
   7  func TestIsOpenMode(t *testing.T) {
   8  	if !IsOpenMode([]byte("none")) {
   9  		t.Fatal("none should be open")
  10  	}
  11  	if IsOpenMode([]byte("follows")) {
  12  		t.Fatal("follows should not be open")
  13  	}
  14  	if IsOpenMode(nil) {
  15  		t.Fatal("nil should not be open")
  16  	}
  17  	if IsOpenMode([]byte("non")) {
  18  		t.Fatal("a short value should not be open")
  19  	}
  20  	if IsOpenMode([]byte("nonex")) {
  21  		t.Fatal("a long value should not be open")
  22  	}
  23  	if IsOpenMode([]byte("nome")) {
  24  		t.Fatal("a same-length different value should not be open")
  25  	}
  26  }
  27