diff --git a/assertion/json/json.go b/assertion/json/json.go index 1f84182..b614c21 100644 --- a/assertion/json/json.go +++ b/assertion/json/json.go @@ -152,10 +152,6 @@ func New( type assertions struct { // failures contains the set of error messages for failed assertions failures []error - // terminal indicates there was a failure in evaluating the assertions that - // should be considered a terminal condition (and therefore the test action - // should not be retried). - terminal bool // exp contains the expected conditions for to be asserted exp *Expect // content is the JSON content we will check @@ -173,13 +169,6 @@ func (a *assertions) Failures() []error { return a.failures } -// Terminal returns true if re-executing the assertions against the same result -// would be pointless. This allows assertions to inform the Spec that retrying -// the same operation would not be necessary. -func (a *assertions) Terminal() bool { - return a.terminal -} - // OK returns true if all contained assertions pass successfully func (a *assertions) OK() bool { if a == nil || a.exp == nil { @@ -229,7 +218,6 @@ func (a *assertions) pathsOK() bool { v := interface{}(nil) if err := json.Unmarshal(a.content, &v); err != nil { a.Fail(JSONUnmarshalError(err, nil)) - a.terminal = true return false } for path, expVal := range a.exp.Paths { @@ -250,7 +238,6 @@ func (a *assertions) pathsOK() bool { expValInt, err := strconv.Atoi(expVal) if err != nil { a.Fail(JSONPathConversionError(path, expVal, got)) - a.terminal = true return false } if expValInt != got.(int) { @@ -261,7 +248,6 @@ func (a *assertions) pathsOK() bool { expValFloat, err := strconv.ParseFloat(expVal, 64) if err != nil { a.Fail(JSONPathConversionError(path, expVal, got)) - a.terminal = true return false } if expValFloat != got.(float64) { @@ -272,7 +258,6 @@ func (a *assertions) pathsOK() bool { expValBool, err := strconv.ParseBool(expVal) if err != nil { a.Fail(JSONPathConversionError(path, expVal, got)) - a.terminal = true return false } if expValBool != got.(bool) { @@ -281,7 +266,6 @@ func (a *assertions) pathsOK() bool { } default: a.Fail(JSONPathConversionError(path, expVal, got)) - a.terminal = true return false } } @@ -300,7 +284,6 @@ func (a *assertions) pathFormatsOK() bool { v := interface{}(nil) if e := json.Unmarshal(a.content, &v); e != nil { a.Fail(JSONUnmarshalError(e, nil)) - a.terminal = true return false } for path, format := range a.exp.PathFormats { @@ -314,7 +297,6 @@ func (a *assertions) pathFormatsOK() bool { ok, err := isFormatted(format, got) if err != nil { a.Fail(JSONFormatError(format, err)) - a.terminal = true return false } if !ok { @@ -342,7 +324,6 @@ func (a *assertions) schemaOK() bool { res, err := gjs.Validate(schemaLoader, docLoader) if err != nil { a.Fail(JSONSchemaValidateError(schemaPath, err)) - a.terminal = true return false } diff --git a/assertion/json/json_test.go b/assertion/json/json_test.go index dbd5755..f914568 100644 --- a/assertion/json/json_test.go +++ b/assertion/json/json_test.go @@ -107,13 +107,11 @@ func TestLength(t *testing.T) { a := gdtjson.New(&exp, c) require.True(a.OK()) - require.False(a.Terminal()) require.Empty(a.Failures()) expLen = 0 a = gdtjson.New(&exp, c) require.False(a.OK()) - require.False(a.Terminal()) failures := a.Failures() require.Len(failures, 1) require.ErrorIs(failures[0], gdterrors.ErrNotEqual) @@ -132,7 +130,6 @@ func TestJSONUnmarshalError(t *testing.T) { a := gdtjson.New(&exp, c) require.False(a.OK()) - require.True(a.Terminal()) failures := a.Failures() require.Len(failures, 1) require.ErrorIs(failures[0], gdtjson.ErrJSONUnmarshalError) @@ -151,7 +148,6 @@ func TestJSONPathError(t *testing.T) { a := gdtjson.New(&exp, c) require.False(a.OK()) - require.False(a.Terminal()) failures := a.Failures() require.Len(failures, 1) require.ErrorIs(failures[0], gdtjson.ErrJSONPathNotFound) @@ -170,7 +166,6 @@ func TestJSONPathConversionError(t *testing.T) { a := gdtjson.New(&exp, c) require.False(a.OK()) - require.True(a.Terminal()) failures := a.Failures() require.Len(failures, 1) require.ErrorIs(failures[0], gdtjson.ErrJSONPathConversionError) @@ -189,7 +184,6 @@ func TestJSONPathNotEqual(t *testing.T) { a := gdtjson.New(&exp, c) require.True(a.OK()) - require.False(a.Terminal()) require.Empty(a.Failures()) exp = gdtjson.Expect{ @@ -200,7 +194,6 @@ func TestJSONPathNotEqual(t *testing.T) { a = gdtjson.New(&exp, c) require.False(a.OK()) - require.False(a.Terminal()) failures := a.Failures() require.Len(failures, 1) require.ErrorIs(failures[0], gdtjson.ErrJSONPathNotEqual) @@ -219,7 +212,6 @@ func TestJSONPathFormatNotFound(t *testing.T) { a := gdtjson.New(&exp, c) require.False(a.OK()) - require.False(a.Terminal()) failures := a.Failures() require.Len(failures, 1) require.ErrorIs(failures[0], gdtjson.ErrJSONPathNotFound) @@ -238,7 +230,6 @@ func TestJSONPathFormatNotEqual(t *testing.T) { a := gdtjson.New(&exp, c) require.True(a.OK()) - require.False(a.Terminal()) require.Empty(a.Failures()) exp = gdtjson.Expect{ @@ -249,7 +240,6 @@ func TestJSONPathFormatNotEqual(t *testing.T) { a = gdtjson.New(&exp, c) require.False(a.OK()) - require.False(a.Terminal()) failures := a.Failures() require.Len(failures, 1) require.ErrorIs(failures[0], gdtjson.ErrJSONFormatNotEqual) diff --git a/types/assertions.go b/types/assertions.go index 787260f..dbb51f7 100644 --- a/types/assertions.go +++ b/types/assertions.go @@ -15,8 +15,4 @@ type Assertions interface { // Failures returns a slice of failure messages indicating which assertions // did not succeed. Failures() []error - // Terminal returns true if re-executing the Assertions against the same - // result would be pointless. This allows Assertions to inform the Spec - // that retrying the same operation would not be necessary. - Terminal() bool }