-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package testkit | ||
|
||
import ( | ||
"github.com/dogmatiq/dogma" | ||
"github.com/dogmatiq/testkit/internal/validation" | ||
) | ||
|
||
// CommandValidationScope returns a [dogma.CommandValidationScope] that can be | ||
// used when testing command validation logic. | ||
func CommandValidationScope(...CommandValidationScopeOption) dogma.CommandValidationScope { | ||
return validation.CommandValidationScope() | ||
} | ||
|
||
// EventValidationScope returns a [dogma.EventValidationScope] that can be used | ||
// when testing event validation logic. | ||
func EventValidationScope(...EventValidationScopeOption) dogma.EventValidationScope { | ||
return validation.EventValidationScope() | ||
} | ||
|
||
// TimeoutValidationScope returns a [dogma.TimeoutValidationScope] that can be | ||
// used when testing timeout validation logic. | ||
func TimeoutValidationScope(...TimeoutValidationScopeOption) dogma.TimeoutValidationScope { | ||
return validation.TimeoutValidationScope() | ||
} | ||
|
||
// CommandValidationScopeOption is an option that changes the behavior of a | ||
// [dogma.CommandValidationScope] created by calling [CommandValidationScope]. | ||
type CommandValidationScopeOption interface { | ||
reservedCommandValidationScopeOption() | ||
} | ||
|
||
// EventValidationScopeOption is an option that changes the behavior of a | ||
// [dogma.EventValidationScope] created by calling [EventValidationScope]. | ||
type EventValidationScopeOption interface { | ||
reservedEventValidationScopeOption() | ||
} | ||
|
||
// TimeoutValidationScopeOption is an option that changes the behavior of a | ||
// [dogma.TimeoutValidationScope] created by calling [TimeoutValidationScope]. | ||
type TimeoutValidationScopeOption interface { | ||
reservedTimeoutValidationScopeOption() | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package testkit_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/dogmatiq/testkit" | ||
) | ||
|
||
func TestValidationScopeCreation(t *testing.T) { | ||
if CommandValidationScope() == nil { | ||
t.Errorf("CommandValidationScope() returned nil") | ||
} | ||
|
||
if EventValidationScope() == nil { | ||
t.Errorf("EventValidationScope() returned nil") | ||
} | ||
|
||
if TimeoutValidationScope() == nil { | ||
t.Errorf("TimeoutValidationScope() returned nil") | ||
} | ||
} |