-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassertions.go
40 lines (32 loc) · 911 Bytes
/
assertions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package qac
import "fmt"
// AssertionResult is the container of verification results.
type AssertionResult struct {
description string
errors []error
}
func (r *AssertionResult) addErrorf(format string, a ...interface{}) {
err := fmt.Errorf(format, a...)
r.addError(err)
}
func (r *AssertionResult) addError(err error) {
r.errors = append(r.errors, err)
}
func (r *AssertionResult) addErrors(errors []error) {
r.errors = append(r.errors, errors...)
}
// Description is the textual representation of the assertion.
func (r *AssertionResult) Description() string {
return r.description
}
// Errors returns the errors list.
func (r *AssertionResult) Errors() []error {
return r.errors
}
// Success returns if an assertion completed with no error.
func (r *AssertionResult) Success() bool {
return len(r.errors) == 0
}
type assertion interface {
verify(context planContext) AssertionResult
}