mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2024-12-11 22:35:40 +01:00
af0629856c
Tests cover most of the cache and download related code paths and specify the expected result of various starting states and external failure modes. Where the current code's behaviour doesn't match a test's expectations, the test is disabled and annotated with a TODO until it can be fixed. Added dependency on `github.com/powerman/check` and ran `go mod vendor`.
34 lines
674 B
Go
34 lines
674 B
Go
package reporting
|
|
|
|
type gotestReporter struct{ test T }
|
|
|
|
func (self *gotestReporter) BeginStory(story *StoryReport) {
|
|
self.test = story.Test
|
|
}
|
|
|
|
func (self *gotestReporter) Enter(scope *ScopeReport) {}
|
|
|
|
func (self *gotestReporter) Report(r *AssertionResult) {
|
|
if !passed(r) {
|
|
self.test.Fail()
|
|
}
|
|
}
|
|
|
|
func (self *gotestReporter) Exit() {}
|
|
|
|
func (self *gotestReporter) EndStory() {
|
|
self.test = nil
|
|
}
|
|
|
|
func (self *gotestReporter) Write(content []byte) (written int, err error) {
|
|
return len(content), nil // no-op
|
|
}
|
|
|
|
func NewGoTestReporter() *gotestReporter {
|
|
return new(gotestReporter)
|
|
}
|
|
|
|
func passed(r *AssertionResult) bool {
|
|
return r.Error == nil && r.Failure == ""
|
|
}
|