Skip to content

Commit

Permalink
Ensure CommandExecutor panics if passed an unrecognized command.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed May 24, 2023
1 parent 5cb19c9 commit 28c6c78
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions enginetest/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"github.com/dogmatiq/dogma"
"github.com/dogmatiq/dogma/fixtures"
"github.com/dogmatiq/testkit/enginetest/internal/app"
)

Expand All @@ -32,5 +33,20 @@ func testCommandExecutor(

x.ExecuteCommand(ctx, &app.IntegrationCommand{})
})

t.Run("it panics if passed an unrecognized command", func(t *testing.T) {
t.Parallel()

defer func() {
actual := fmt.Sprint(recover())
expect := "MessageC" // the type name should appear in the message

if !strings.Contains(actual, expect) {
t.Fatalf("got: %q, want: panic containing %q", actual, expect)
}
}()

x.ExecuteCommand(ctx, fixtures.MessageC1)
})
})
}

0 comments on commit 28c6c78

Please sign in to comment.