diff --git a/src/scribe/result.go b/src/scribe/result.go index e449c40..038e47b 100644 --- a/src/scribe/result.go +++ b/src/scribe/result.go @@ -15,34 +15,25 @@ import ( // Describes the results of a test. The type can be marshaled into a JSON // string as required. type TestResult struct { - // The name of the test. - Name string `json:"name"` - // The identifier for the test. - Identifier string `json:"identifier"` - // Aliases for the test. - Aliases []string `json:"aliases"` + Name string `json:"name"` // The name of the test. + Identifier string `json:"identifier"` // The identifier for the test. + Aliases []string `json:"aliases"` // Aliases for the test. - // True if error encountered during evaluation. - IsError bool `json:"iserror"` - // Error associated with test. - Error string `json:"error"` + IsError bool `json:"iserror"` // True of error is encountered during evaluation. + Error string `json:"error"` // Error associated with test. - // Master result of test. - MasterResult bool `json:"masterresult"` - // True if some source evaluations resulted in the test being true. - HasTrueResults bool `json:"hastrueresults"` + MasterResult bool `json:"masterresult"` // Master result of test. + HasTrueResults bool `json:"hastrueresults"` // True if > 0 evaluations resulted in true. - Results []TestSubResult `json:"results"` + Results []TestSubResult `json:"results"` // The sub-results for the test. } // For a given test, a number of sources can be identified that match the // criteria. For example, multiple files can be identifier with a given // filename. Each test tracks individual results for these cases. type TestSubResult struct { - // The result of evaluation for an identifier source. - Result bool `json:"result"` - // The identifier for the source. - Identifier string `json:"identifier"` + Result bool `json:"result"` // The result of evaluation for an identifier source. + Identifier string `json:"identifier"` // The identifier for the source. } // Return test results for a given test. Returns an error if an diff --git a/src/scribe/test.go b/src/scribe/test.go index c1024fe..1fe06e6 100644 --- a/src/scribe/test.go +++ b/src/scribe/test.go @@ -25,48 +25,37 @@ type test struct { Expected bool `json:"expectedresult"` - // true if test has been prepared. - prepared bool + prepared bool // True if test has been prepared. + evaluated bool // True if test has been evaluated at least once. - // true if test has been evaluated at least once. - evaluated bool - - // The last error condition encountered during preparation - // or execution. nil if no error occurred. - err error + err error // The last error condition encountered during preparation or execution. // The final result for this test, a rolled up version of the results // of this test for any identified candidates. If at least one // candidate for the test evaluated to true, the master result will be // true. - masterResult bool - - // True if at least one result evaluated to true. - hasTrueResults bool - - // Stores a slice of results for this test. - results []evaluationResult + masterResult bool // The final result for the test. + hasTrueResults bool // True if at least one result evaluated to true. + results []evaluationResult // A slice of results for the test. } // The result of evaluation of a test. There can be more then one // EvaluationResult present in the results of a test, if the source // information returned more than one matching object. type evaluationResult struct { - // The criteria used during evaluation. - criteria evaluationCriteria - // The result of the evaluation. - result bool + criteria evaluationCriteria // Criteria used during evaluation. + result bool // The result of the evaluation. } // Generic criteria for an evaluation. A source object should always support // conversion from the specific type to a set of evaluation criteria. +// +// An identifier is used to track the source of an evaluation. For example, +// this may be a filename or a package name. In those examples, the testValue +// may be matched content from the file, or a package version string. type evaluationCriteria struct { - // An identifier used to track the source of a failed evaluation. For - // example, this may be a filename, if the TestValue is content from - // the file. - identifier string - // The actual test data used in the evaluator. - testValue string + identifier string // The identifier used to track the source. + testValue string // the actual test data passed to the evaluator. } type genericSource interface {