github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/agent/structs/prepared_query_test.go (about)

     1  package structs
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestStructs_PreparedQuery_GetACLPrefix(t *testing.T) {
     8  	ephemeral := &PreparedQuery{}
     9  	if prefix, ok := ephemeral.GetACLPrefix(); ok {
    10  		t.Fatalf("bad: %s", prefix)
    11  	}
    12  
    13  	named := &PreparedQuery{
    14  		Name: "hello",
    15  	}
    16  	if prefix, ok := named.GetACLPrefix(); !ok || prefix != "hello" {
    17  		t.Fatalf("bad: ok=%v, prefix=%#v", ok, prefix)
    18  	}
    19  
    20  	tmpl := &PreparedQuery{
    21  		Name: "",
    22  		Template: QueryTemplateOptions{
    23  			Type: QueryTemplateTypeNamePrefixMatch,
    24  		},
    25  	}
    26  	if prefix, ok := tmpl.GetACLPrefix(); !ok || prefix != "" {
    27  		t.Fatalf("bad: ok=%v prefix=%#v", ok, prefix)
    28  	}
    29  }