Created
August 29, 2021 11:17
-
-
Save percybolmer/0b224049ddd07b73aa465f056d5db735 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package aggregate_test | |
import ( | |
"testing" | |
"github.com/percybolmer/ddd-go/aggregate" | |
) | |
func TestProduct_NewProduct(t *testing.T) { | |
type testCase struct { | |
test string | |
name string | |
description string | |
price float64 | |
expectedErr error | |
} | |
testCases := []testCase{ | |
{ | |
test: "should return error if name is empty", | |
name: "", | |
expectedErr: aggregate.ErrMissingValues, | |
}, | |
{ | |
test: "validvalues", | |
name: "test", | |
description: "test", | |
price: 1.0, | |
expectedErr: nil, | |
}, | |
} | |
for _, tc := range testCases { | |
t.Run(tc.test, func(t *testing.T) { | |
_, err := aggregate.NewProduct(tc.name, tc.description, tc.price) | |
if err != tc.expectedErr { | |
t.Errorf("Expected error: %v, got: %v", tc.expectedErr, err) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment