github.com/zorawar87/trillian@v1.2.1/quota/quota_test.go (about)

     1  // Copyright 2017 Google Inc. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package quota
    16  
    17  import "testing"
    18  
    19  func TestSpec_Name(t *testing.T) {
    20  	tests := []struct {
    21  		spec Spec
    22  		want string
    23  	}{
    24  		{spec: Spec{Group: Global, Kind: Read}, want: "global/read"},
    25  		{spec: Spec{Group: Global, Kind: Write}, want: "global/write"},
    26  		{spec: Spec{Group: Tree, Kind: Read, TreeID: 11}, want: "trees/11/read"},
    27  		{spec: Spec{Group: Tree, Kind: Write, TreeID: 10}, want: "trees/10/write"},
    28  		{spec: Spec{Group: User, Kind: Read, User: "alpaca"}, want: "users/alpaca/read"},
    29  		{spec: Spec{Group: User, Kind: Write, User: "llama"}, want: "users/llama/write"},
    30  	}
    31  	for _, test := range tests {
    32  		if got := test.spec.Name(); got != test.want {
    33  			t.Errorf("%#v.Name() = %v, want = %v", test.spec, got, test.want)
    34  		}
    35  	}
    36  }