53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
|
package moduletest
|
||
|
|
||
|
import (
|
||
|
"github.com/hashicorp/terraform/tfdiags"
|
||
|
)
|
||
|
|
||
|
// Assertion is the description of a single test assertion, whether
|
||
|
// successful or unsuccessful.
|
||
|
type Assertion struct {
|
||
|
Outcome Status
|
||
|
|
||
|
// Description is a user-provided, human-readable description of what
|
||
|
// this assertion represents.
|
||
|
Description string
|
||
|
|
||
|
// Message is typically relevant only for TestFailed or TestError
|
||
|
// assertions, giving a human-readable description of the problem,
|
||
|
// formatted in the way our format package expects to receive paragraphs
|
||
|
// for terminal word wrapping.
|
||
|
Message string
|
||
|
|
||
|
// Diagnostics includes diagnostics specific to the current test assertion,
|
||
|
// if available.
|
||
|
Diagnostics tfdiags.Diagnostics
|
||
|
}
|
||
|
|
||
|
// Component represents a component being tested, each of which can have
|
||
|
// several associated test assertions.
|
||
|
type Component struct {
|
||
|
Assertions map[string]*Assertion
|
||
|
}
|
||
|
|
||
|
// Status is an enumeration of possible outcomes of a test assertion.
|
||
|
type Status rune
|
||
|
|
||
|
const (
|
||
|
// Pending indicates that the test was registered (during planning)
|
||
|
// but didn't register an outcome during apply, perhaps due to being
|
||
|
// blocked by some other upstream failure.
|
||
|
Pending Status = '?'
|
||
|
|
||
|
// Passed indicates that the test condition succeeded.
|
||
|
Passed Status = 'P'
|
||
|
|
||
|
// Failed indicates that the test condition was valid but did not
|
||
|
// succeed.
|
||
|
Failed Status = 'F'
|
||
|
|
||
|
// Error indicates that the test condition was invalid or that the
|
||
|
// test report failed in some other way.
|
||
|
Error Status = 'E'
|
||
|
)
|