github.com/greenpau/go-identity@v1.1.6/credit_card_test.go (about)

     1  // Copyright 2020 Paul Greenberg greenpau@outlook.com
     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 identity
    16  
    17  import (
    18  	"testing"
    19  )
    20  
    21  func TestNewCreditCard(t *testing.T) {
    22  	cc := NewCreditCard()
    23  	if err := cc.AddIssuer("citigroup"); err == nil {
    24  		t.Fatalf("citigroup is unsupported issuer, received success, expected failure")
    25  	}
    26  	issuer := NewCreditCardIssuer()
    27  	issuer.Name = "Citigroup"
    28  	issuer.Aliases = []string{
    29  		"citi", "citibank",
    30  	}
    31  	CreditCardIssuers = append(CreditCardIssuers, issuer)
    32  	if err := cc.AddIssuer("citigroup"); err != nil {
    33  		t.Fatalf("Citigroup became supported issuer, received error: %s, expected success", err)
    34  	}
    35  	if err := cc.AddIssuer("citibank"); err != nil {
    36  		t.Fatalf("Citigroup has an alias citibank, received error: %s, expected success", err)
    37  	}
    38  }