Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created August 29, 2021 11:17
Show Gist options
  • Save percybolmer/0b224049ddd07b73aa465f056d5db735 to your computer and use it in GitHub Desktop.
Save percybolmer/0b224049ddd07b73aa465f056d5db735 to your computer and use it in GitHub Desktop.
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