Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove renderer. #174

Merged
merged 4 commits into from
Nov 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions assert/assertion.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package assert
import (
"github.com/dogmatiq/testkit/compare"
"github.com/dogmatiq/testkit/engine/fact"
"github.com/dogmatiq/testkit/render"
)

// ExpectOptionSet is a set of options that dictate the behavior of the
Expand Down Expand Up @@ -46,5 +45,5 @@ type Assertion interface {
// ok is true if the assertion is considered to have passed. This may not be
// the same value as returned from Ok() when this assertion is used as a
// sub-assertion inside a composite.
BuildReport(ok bool, r render.Renderer) *Report
BuildReport(ok bool) *Report
}
24 changes: 12 additions & 12 deletions assert/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/dogmatiq/testkit/engine/envelope"
"github.com/dogmatiq/testkit/engine/fact"
"github.com/dogmatiq/testkit/internal/inflect"
"github.com/dogmatiq/testkit/render"
"github.com/dogmatiq/testkit/report"
)

// CommandExecuted returns an assertion that passes if m is executed as a
Expand Down Expand Up @@ -120,7 +120,7 @@ func (a *messageAssertion) Ok() bool {
// ok is true if the assertion is considered to have passed. This may not be the
// same value as returned from Ok() when this assertion is used as a
// sub-assertion inside a composite.
func (a *messageAssertion) BuildReport(ok bool, r render.Renderer) *Report {
func (a *messageAssertion) BuildReport(ok bool) *Report {
rep := &Report{
TreeOk: ok,
Ok: a.ok,
Expand All @@ -138,9 +138,9 @@ func (a *messageAssertion) BuildReport(ok bool, r render.Renderer) *Report {
if a.best == nil {
buildResultNoMatch(rep, &a.tracker)
} else if a.best.Role == a.role {
a.buildResultExpectedRole(r, rep)
a.buildResultExpectedRole(rep)
} else {
a.buildResultUnexpectedRole(r, rep)
a.buildResultUnexpectedRole(rep)
}

return rep
Expand Down Expand Up @@ -200,7 +200,7 @@ func (a *messageAssertion) updateBestMatch(env *envelope.Envelope) {

// buildResultExpectedRole builds the assertion result when there is a
// "best-match" message available and it is of the expected role.
func (a *messageAssertion) buildResultExpectedRole(r render.Renderer, rep *Report) {
func (a *messageAssertion) buildResultExpectedRole(rep *Report) {
s := rep.Section(suggestionsSection)

if a.sim == compare.SameTypes {
Expand Down Expand Up @@ -240,21 +240,21 @@ func (a *messageAssertion) buildResultExpectedRole(r render.Renderer, rep *Repor
s.AppendListItem("check the message type, should it be a pointer?")
}

a.buildDiff(r, rep)
a.buildDiff(rep)
}

// buildDiff adds a "message diff" section to the result.
func (a *messageAssertion) buildDiff(r render.Renderer, rep *Report) {
render.WriteDiff(
func (a *messageAssertion) buildDiff(rep *Report) {
report.WriteDiff(
&rep.Section("Message Diff").Content,
render.Message(r, a.expected),
render.Message(r, a.best.Message),
report.RenderMessage(a.expected),
report.RenderMessage(a.best.Message),
)
}

// buildResultUnexpectedRole builds the assertion result when there is a
// "best-match" message available but it is of an unexpected role.
func (a *messageAssertion) buildResultUnexpectedRole(r render.Renderer, rep *Report) {
func (a *messageAssertion) buildResultUnexpectedRole(rep *Report) {
s := rep.Section(suggestionsSection)

if a.best.Origin == nil {
Expand Down Expand Up @@ -332,5 +332,5 @@ func (a *messageAssertion) buildResultUnexpectedRole(r render.Renderer, rep *Rep
s.AppendListItem("check the message type, should it be a pointer?")
}

a.buildDiff(r, rep)
a.buildDiff(rep)
}
14 changes: 7 additions & 7 deletions assert/messagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/dogmatiq/testkit/engine/envelope"
"github.com/dogmatiq/testkit/engine/fact"
"github.com/dogmatiq/testkit/internal/inflect"
"github.com/dogmatiq/testkit/render"
"github.com/dogmatiq/testkit/report"
)

// CommandTypeExecuted returns an assertion that passes if a message with the
Expand Down Expand Up @@ -95,7 +95,7 @@ func (a *messageTypeAssertion) Ok() bool {
// ok is true if the assertion is considered to have passed. This may not be the
// same value as returned from Ok() when this assertion is used as a
// sub-assertion inside a composite.
func (a *messageTypeAssertion) BuildReport(ok bool, r render.Renderer) *Report {
func (a *messageTypeAssertion) BuildReport(ok bool) *Report {
rep := &Report{
TreeOk: ok,
Ok: a.ok,
Expand All @@ -113,9 +113,9 @@ func (a *messageTypeAssertion) BuildReport(ok bool, r render.Renderer) *Report {
if a.best == nil {
buildResultNoMatch(rep, &a.tracker)
} else if a.best.Role == a.role {
a.buildResultExpectedRole(r, rep)
a.buildResultExpectedRole(rep)
} else {
a.buildResultUnexpectedRole(r, rep)
a.buildResultUnexpectedRole(rep)
}

return rep
Expand Down Expand Up @@ -163,7 +163,7 @@ func (a *messageTypeAssertion) messageProduced(env *envelope.Envelope) {

// buildDiff adds a "message type diff" section to the result.
func (a *messageTypeAssertion) buildDiff(rep *Report) {
render.WriteDiff(
report.WriteDiff(
&rep.Section("Message Type Diff").Content,
a.expected.String(),
a.best.Type.ReflectType().String(),
Expand All @@ -172,7 +172,7 @@ func (a *messageTypeAssertion) buildDiff(rep *Report) {

// buildResultExpectedRole builds the assertion result when there is a
// "best-match" message available but it is of an unexpected role.
func (a *messageTypeAssertion) buildResultExpectedRole(r render.Renderer, rep *Report) {
func (a *messageTypeAssertion) buildResultExpectedRole(rep *Report) {
s := rep.Section(suggestionsSection)

if a.best.Origin == nil {
Expand All @@ -198,7 +198,7 @@ func (a *messageTypeAssertion) buildResultExpectedRole(r render.Renderer, rep *R

// buildResultUnexpectedRole builds the assertion result when there is a
// "best-match" message available but it is of an expected role.
func (a *messageTypeAssertion) buildResultUnexpectedRole(r render.Renderer, rep *Report) {
func (a *messageTypeAssertion) buildResultUnexpectedRole(rep *Report) {
s := rep.Section(suggestionsSection)

if a.best.Origin == nil {
Expand Down
5 changes: 2 additions & 3 deletions composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/dogmatiq/testkit/assert"
"github.com/dogmatiq/testkit/engine/fact"
"github.com/dogmatiq/testkit/render"
)

// AllOf is an expectation that passes only if all of its children pass.
Expand Down Expand Up @@ -191,7 +190,7 @@ func (e *compositeExpectation) Ok() bool {
// ok is true if the expectation is considered to have passed. This may not be
// the same value as returned from Ok() when this expectation is used as a child
// of a composite expectation.
func (e *compositeExpectation) BuildReport(ok bool, r render.Renderer) *assert.Report {
func (e *compositeExpectation) BuildReport(ok bool) *assert.Report {
e.Ok() // populate e.ok and e.outcome

rep := &assert.Report{
Expand All @@ -203,7 +202,7 @@ func (e *compositeExpectation) BuildReport(ok bool, r render.Renderer) *assert.R

for _, c := range e.Children {
rep.Append(
c.BuildReport(ok, r),
c.BuildReport(ok),
)
}

Expand Down
3 changes: 1 addition & 2 deletions expectation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
. "github.com/dogmatiq/testkit"
"github.com/dogmatiq/testkit/assert"
"github.com/dogmatiq/testkit/engine/fact"
"github.com/dogmatiq/testkit/render"
)

const (
Expand All @@ -31,7 +30,7 @@ func (a staticExpectation) Begin(ExpectOptionSet) {}
func (a staticExpectation) End() {}
func (a staticExpectation) Ok() bool { return bool(a) }
func (a staticExpectation) Notify(fact.Fact) {}
func (a staticExpectation) BuildReport(ok bool, r render.Renderer) *assert.Report {
func (a staticExpectation) BuildReport(ok bool) *assert.Report {
c := "<always fail>"
if a {
c = "<always pass>"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.15
require (
github.com/dogmatiq/configkit v0.9.1
github.com/dogmatiq/cosyne v0.1.0
github.com/dogmatiq/dapper v0.4.0
github.com/dogmatiq/dapper v0.4.1
github.com/dogmatiq/dogma v0.10.0
github.com/dogmatiq/iago v0.4.0
github.com/dogmatiq/linger v0.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ github.com/dogmatiq/configkit v0.9.1 h1:gx2egDrmeiel1m8/RwAOk3ZFlvZa1mmElPz9v1K0
github.com/dogmatiq/configkit v0.9.1/go.mod h1:lchVdCxCweenWrmm9WlgRH9X7Ppb340CvilcoVdTE8c=
github.com/dogmatiq/cosyne v0.1.0 h1:j7b5WEZz7d+jfTP3JRgKpCWTsfaf4E1Z0s65A6yW9ic=
github.com/dogmatiq/cosyne v0.1.0/go.mod h1:/OyJ0EHpWAZFt8/793nFrn6JIr7WSG4Zf+jlowBnCtw=
github.com/dogmatiq/dapper v0.4.0 h1:WshL6xcW56jxkh1XE/x7sXyzxOvjBFjMcxz1jdjwn60=
github.com/dogmatiq/dapper v0.4.0/go.mod h1:U32cRxzGYI5owhc/hMKjYLgBTVCdW/s3MdFJHwfDrLQ=
github.com/dogmatiq/dapper v0.4.1 h1:HULzWJulT93izao/24QUpQYRDTG0ELSL4c13+BRbw5g=
github.com/dogmatiq/dapper v0.4.1/go.mod h1:U32cRxzGYI5owhc/hMKjYLgBTVCdW/s3MdFJHwfDrLQ=
github.com/dogmatiq/dogma v0.10.0 h1:2kLivwq72nr6yF3/jpIA5U57IOmPRxeO+I9lE06IebE=
github.com/dogmatiq/dogma v0.10.0/go.mod h1:8TdjQ5jjV2DcCPb/jjHPgSrqU66H6092yMEIF5HGx0g=
github.com/dogmatiq/iago v0.4.0 h1:57nZqVT34IZxtCZEW/RFif7DNUEjMXgevfr/Mmd0N8I=
Expand Down
3 changes: 0 additions & 3 deletions render/doc.go

This file was deleted.

134 changes: 0 additions & 134 deletions render/renderer.go

This file was deleted.

Loading