-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase Code Coverage
- Loading branch information
Showing
12 changed files
with
451 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
package wire | ||
|
||
import ( | ||
"github.com/moov-io/base" | ||
"testing" | ||
) | ||
|
||
// mockAccountCreditedDrawdown creates a AccountCreditedDrawdown | ||
func mockAccountCreditedDrawdown() *AccountCreditedDrawdown { | ||
creditDD := NewAccountCreditedDrawdown() | ||
creditDD.DrawdownCreditAccountNumber = "123456789" | ||
return creditDD | ||
} | ||
|
||
// TestMockAccountCreditedDrawdown validates mockAccountCreditedDrawdown | ||
func TestMockAccountCreditedDrawdown(t *testing.T) { | ||
creditDD := mockAccountCreditedDrawdown() | ||
if err := creditDD.Validate(); err != nil { | ||
t.Error("mockAccountCreditedDrawdown does not validate and will break other tests") | ||
} | ||
} | ||
|
||
// TestDrawdownCreditAccountNumberAlphaNumeric validates DrawdownCreditAccountNumber is alphanumeric | ||
func TestDrawdownCreditAccountNumberAlphaNumeric(t *testing.T) { | ||
creditDD := mockAccountCreditedDrawdown() | ||
creditDD.DrawdownCreditAccountNumber = "®" | ||
if err := creditDD.Validate(); err != nil { | ||
if !base.Match(err, ErrNonAlphanumeric) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestDrawdownCreditAccountNumberRequired validates DrawdownCreditAccountNumber is required | ||
func TestDrawdownCreditAccountNumberRequired(t *testing.T) { | ||
creditDD := mockAccountCreditedDrawdown() | ||
creditDD.DrawdownCreditAccountNumber = "" | ||
if err := creditDD.Validate(); err != nil { | ||
if !base.Match(err, ErrFieldRequired) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,125 @@ | ||
package wire | ||
|
||
import ( | ||
"github.com/moov-io/base" | ||
"testing" | ||
) | ||
|
||
// mockAccountDebitedDrawdown creates a AccountDebitedDrawdown | ||
func mockAccountDebitedDrawdown() *AccountDebitedDrawdown { | ||
debitDD := NewAccountDebitedDrawdown() | ||
debitDD.IdentificationCode = "DemandDepositAccountNumber" | ||
debitDD.IdentificationCode = DemandDepositAccountNumber | ||
debitDD.Identifier = "123456789" | ||
debitDD.Name = "debitDD Name" | ||
debitDD.Address.AddressLineOne = "Address One" | ||
debitDD.Address.AddressLineTwo = "Address Two" | ||
debitDD.Address.AddressLineThree = "Address Three" | ||
return debitDD | ||
} | ||
|
||
// TestMockAccountDebitedDrawdown validates mockAccountDebitedDrawdown | ||
func TestMockAccountDebitedDrawdown(t *testing.T) { | ||
debitDD := mockAccountDebitedDrawdown() | ||
if err := debitDD.Validate(); err != nil { | ||
t.Error("mockAccountDebitedDrawdown does not validate and will break other tests") | ||
} | ||
} | ||
|
||
// TestIdentifierAlphaNumeric validates Name is alphanumeric | ||
func TestIdentifierAlphaNumeric(t *testing.T) { | ||
debitDD := mockAccountDebitedDrawdown() | ||
debitDD.Identifier = "®" | ||
if err := debitDD.Validate(); err != nil { | ||
if !base.Match(err, ErrNonAlphanumeric) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestNameAlphaNumeric validates Identifier is alphanumeric | ||
func TestNameAlphaNumeric(t *testing.T) { | ||
debitDD := mockAccountDebitedDrawdown() | ||
debitDD.Name = "®" | ||
if err := debitDD.Validate(); err != nil { | ||
if !base.Match(err, ErrNonAlphanumeric) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestAddressLineOneAlphaNumeric validates AddressLineOne is alphanumeric | ||
func TestAddressLineOneAlphaNumeric(t *testing.T) { | ||
debitDD := mockAccountDebitedDrawdown() | ||
debitDD.Address.AddressLineOne = "®" | ||
if err := debitDD.Validate(); err != nil { | ||
if !base.Match(err, ErrNonAlphanumeric) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestAddressLineTwoAlphaNumeric validates AddressLineTwo is alphanumeric | ||
func TestAddressLineTwoAlphaNumeric(t *testing.T) { | ||
debitDD := mockAccountDebitedDrawdown() | ||
debitDD.Address.AddressLineTwo = "®" | ||
if err := debitDD.Validate(); err != nil { | ||
if !base.Match(err, ErrNonAlphanumeric) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestAddressLineThreeAlphaNumeric validates AddressLineThree is alphanumeric | ||
func TestAddressLineThreeAlphaNumeric(t *testing.T) { | ||
debitDD := mockAccountDebitedDrawdown() | ||
debitDD.Address.AddressLineThree = "®" | ||
if err := debitDD.Validate(); err != nil { | ||
if !base.Match(err, ErrNonAlphanumeric) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestIdentifierRequired validates Identifier is required | ||
func TestIdentifierRequired(t *testing.T) { | ||
debitDD := mockAccountDebitedDrawdown() | ||
debitDD.Identifier = "" | ||
if err := debitDD.Validate(); err != nil { | ||
if !base.Match(err, ErrFieldRequired) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestNameRequired validates Name is required | ||
func TestNameRequired(t *testing.T) { | ||
debitDD := mockAccountDebitedDrawdown() | ||
debitDD.Name = "" | ||
if err := debitDD.Validate(); err != nil { | ||
if !base.Match(err, ErrFieldRequired) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestIdentificationRequired validates IdentificationCode is required | ||
func TestIdentificationCodeNull(t *testing.T) { | ||
debitDD := mockAccountDebitedDrawdown() | ||
debitDD.IdentificationCode = "" | ||
if err := debitDD.Validate(); err != nil { | ||
if !base.Match(err, ErrFieldRequired) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestIdentificationCodeValid validates IdentificationCode | ||
func TestIdentificationCodeRequired(t *testing.T) { | ||
debitDD := mockAccountDebitedDrawdown() | ||
debitDD.IdentificationCode = TaxIdentificationNumber | ||
if err := debitDD.Validate(); err != nil { | ||
if !base.Match(err, ErrIdentificationCode) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,66 @@ | ||
package wire | ||
|
||
import ( | ||
"github.com/moov-io/base" | ||
"testing" | ||
) | ||
|
||
// ActualAmountPaid creates a ActualAmountPaid | ||
func mockActualAmountPaid() *ActualAmountPaid { | ||
aap := NewActualAmountPaid() | ||
aap.RemittanceAmount.CurrencyCode = "USD" | ||
aap.RemittanceAmount.Amount = "1234.56" | ||
return aap | ||
} | ||
|
||
// TestMockActualAmountPaid validates mockActualAmountPaid | ||
func TestMockActualAmountPaid(t *testing.T) { | ||
aap := mockActualAmountPaid() | ||
if err := aap.Validate(); err != nil { | ||
t.Error("mockActualAmountPaid does not validate and will break other tests") | ||
} | ||
} | ||
|
||
// TestAmountRequired validates Amount is required | ||
func TestAmountRequired(t *testing.T) { | ||
aap := mockActualAmountPaid() | ||
aap.RemittanceAmount.Amount = "" | ||
if err := aap.Validate(); err != nil { | ||
if !base.Match(err, ErrFieldRequired) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestCurrencyCodeRequired validates CurrencyCode is required | ||
func TestCurrencyCodeRequired(t *testing.T) { | ||
aap := mockActualAmountPaid() | ||
aap.RemittanceAmount.CurrencyCode = "" | ||
if err := aap.Validate(); err != nil { | ||
if !base.Match(err, ErrFieldRequired) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestAmountValid validates Amount | ||
func TestAmountValid(t *testing.T) { | ||
aap := mockActualAmountPaid() | ||
aap.RemittanceAmount.Amount = "X," | ||
if err := aap.Validate(); err != nil { | ||
if !base.Match(err, ErrNonAmount) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestCurrencyCodeValid validates Amount | ||
func TestCurrencyCodeValid(t *testing.T) { | ||
aap := mockActualAmountPaid() | ||
aap.RemittanceAmount.CurrencyCode = "XZP" | ||
if err := aap.Validate(); err != nil { | ||
if !base.Match(err, ErrNonCurrencyCode) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.