Skip to content

Instantly share code, notes, and snippets.

@hexfusion
Created April 10, 2022 18:08
Show Gist options
  • Save hexfusion/f2053003fc6fa142b2c3a5e7e0da473c to your computer and use it in GitHub Desktop.
Save hexfusion/f2053003fc6fa142b2c3a5e7e0da473c to your computer and use it in GitHub Desktop.
func Test_NewAggregate(t *testing.T) {
assert := assert.New(t)
scenarios := []struct {
name string
errs []error
wantNil bool
}{
{
name: "no errors",
errs: nil,
wantNil: true,
},
{
name: "concat errors",
errs: []error{errors.New("foo"), errors.New("bar")},
},
}
for _, scenario := range scenarios {
t.Run(scenario.name, func(t *testing.T) {
err := NewAggregate(scenario.errs)
if scenario.wantNil {
assert.Nil(err)
return
}
assert.NotNil(err)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment