Skip to content

Commit

Permalink
Add tests for nil routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Nov 6, 2024
1 parent 04e17c4 commit 566bd5f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 108 deletions.
3 changes: 3 additions & 0 deletions config/staticconfig/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func analyzeRoute[
r ssa.Value,
) {
switch r := r.(type) {
case *ssa.Const:
// We've found a nil route.

case *ssa.MakeInterface:
analyzeRoute(ctx, b, r.X)

Expand Down

This file was deleted.

50 changes: 0 additions & 50 deletions config/staticconfig/testdata/_pending/nil-routes-in-handlers.md

This file was deleted.

37 changes: 37 additions & 0 deletions config/staticconfig/testdata/handler-with-nil-route.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Handler with nil route

This test verifies that the static analyzer correctly detects a `nil` route.

```au:output au:group=matrix
valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable)
- valid identity app/e4183527-c234-42d5-8709-3dc8b9d5caa4
- invalid integration github.com/dogmatiq/enginekit/config/staticconfig.Integration (value unavailable)
- no handles-command routes
- valid identity handler/5752bb84-0b65-4a7f-b2fa-bfb77a53a97f
- incomplete route
- route type is unavailable
- message type name is unavailable
```

```go au:input au:group=matrix
package app

import "context"
import "github.com/dogmatiq/dogma"

type Integration struct{}

func (Integration) Configure(c dogma.IntegrationConfigurer) {
c.Identity("handler", "5752bb84-0b65-4a7f-b2fa-bfb77a53a97f")
c.Routes(nil)
}

func (Integration) HandleCommand(context.Context, dogma.IntegrationCommandScope, dogma.Command) error { return nil }

type App struct{}

func (App) Configure(c dogma.ApplicationConfigurer) {
c.Identity("app", "e4183527-c234-42d5-8709-3dc8b9d5caa4")
c.RegisterIntegration(Integration{})
}
```

0 comments on commit 566bd5f

Please sign in to comment.