github.com/shashidharatd/test-infra@v0.0.0-20171006011030-71304e1ca560/prow/github/types_test.go (about)

     1  /*
     2  Copyright 2017 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package github
    18  
    19  import (
    20  	"testing"
    21  )
    22  
    23  func TestIssueCapsLogin(t *testing.T) {
    24  	// some valid logins that should all normalize to match the first
    25  	validLoginVariants := []string{
    26  		"BenTheElder",
    27  		"BENTHEELDER",
    28  		"bentheelder",
    29  		"BenTHEElder",
    30  		"BeNtHeElDeR",
    31  		"bEnThEeLdEr",
    32  	}
    33  	// add an explicitly normalized version for sanity
    34  	validLoginVariants = append(validLoginVariants, NormLogin(validLoginVariants[0]))
    35  
    36  	issue := Issue{
    37  		User: User{
    38  			Login: validLoginVariants[0],
    39  		},
    40  		Assignees: []User{
    41  			{
    42  				Login: validLoginVariants[0],
    43  			},
    44  		},
    45  	}
    46  	for _, login := range validLoginVariants {
    47  		if !issue.IsAuthor(login) {
    48  			t.Errorf("expected issue.IsAuthor(%s) to be true", login)
    49  		}
    50  		if !issue.IsAssignee(login) {
    51  			t.Errorf("expected issue.IsAssignee(%s) to be true", login)
    52  		}
    53  	}
    54  }