-
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.
Additional tests and gocyclo coverage
Additional tests and gocyclo coverage
- Loading branch information
Showing
12 changed files
with
562 additions
and
80 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,65 @@ | ||
package wire | ||
|
||
import ( | ||
"github.com/moov-io/base" | ||
"testing" | ||
) | ||
|
||
// AmountNegotiatedDiscount creates a AmountNegotiatedDiscount | ||
func mockAmountNegotiatedDiscount() *AmountNegotiatedDiscount { | ||
nd := NewAmountNegotiatedDiscount() | ||
nd.RemittanceAmount.CurrencyCode = "USD" | ||
nd.RemittanceAmount.Amount = "1234.56" | ||
return nd | ||
} | ||
|
||
// TestMockAmountNegotiatedDiscount validates mockAmountNegotiatedDiscount | ||
func TestMockAmountNegotiatedDiscount(t *testing.T) { | ||
nd := mockAmountNegotiatedDiscount() | ||
if err := nd.Validate(); err != nil { | ||
t.Error("mockAmountNegotiatedDiscount does not validate and will break other tests") | ||
} | ||
} | ||
|
||
// TestAmountNegotiatedDiscountAmountValid validates AmountNegotiatedDiscount Amount | ||
func TestAmountNegotiatedDiscountValid(t *testing.T) { | ||
nd := mockAmountNegotiatedDiscount() | ||
nd.RemittanceAmount.Amount = "X," | ||
if err := nd.Validate(); err != nil { | ||
if !base.Match(err, ErrNonAmount) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestAmountNegotiatedDiscountCurrencyCodeValid validates AmountNegotiatedDiscount CurrencyCode | ||
func TestAmountNegotiatedDiscountCurrencyCodeValid(t *testing.T) { | ||
nd := mockAmountNegotiatedDiscount() | ||
nd.RemittanceAmount.CurrencyCode = "XZP" | ||
if err := nd.Validate(); err != nil { | ||
if !base.Match(err, ErrNonCurrencyCode) { | ||
} | ||
} | ||
} | ||
|
||
// TestAmountNegotiatedDiscountAmountRequired validates AmountNegotiatedDiscount Amount is required | ||
func TestAmountNegotiatedDiscountRequired(t *testing.T) { | ||
nd := mockAmountNegotiatedDiscount() | ||
nd.RemittanceAmount.Amount = "" | ||
if err := nd.Validate(); err != nil { | ||
if !base.Match(err, ErrFieldRequired) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestAmountNegotiatedDiscountCurrencyCodeRequired validates AmountNegotiatedDiscount CurrencyCode is required | ||
func TestAmountNegotiatedDiscountCurrencyCodeRequired(t *testing.T) { | ||
nd := mockAmountNegotiatedDiscount() | ||
nd.RemittanceAmount.CurrencyCode = "" | ||
if err := nd.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
package wire | ||
|
||
import ( | ||
"github.com/moov-io/base" | ||
"testing" | ||
) | ||
|
||
// mockAmount creates an a Amount | ||
func mockAmount() *Amount { | ||
a := NewAmount() | ||
a.Amount = "000001234567" | ||
return a | ||
} | ||
|
||
// TestMockAmount validates mockAmount | ||
func TestMockAmount(t *testing.T) { | ||
a := mockAmount() | ||
if err := a.Validate(); err != nil { | ||
t.Error("mockAmount does not validate and will break other tests") | ||
} | ||
} | ||
|
||
// TestAmountValid validates Amount | ||
func TestAmountValid(t *testing.T) { | ||
a := mockAmount() | ||
a.Amount = "X," | ||
if err := a.Validate(); err != nil { | ||
if !base.Match(err, ErrNonAmount) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} | ||
|
||
// TestAmountRequired validates Amount is required | ||
func TestAmountRequired(t *testing.T) { | ||
a := mockAmount() | ||
a.Amount = "" | ||
if err := a.Validate(); err != nil { | ||
if !base.Match(err, ErrFieldRequired) { | ||
t.Errorf("%T: %s", err, err) | ||
} | ||
} | ||
} |
Oops, something went wrong.