Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused Assertions.Terminal() interface #17

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions assertion/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -281,7 +266,6 @@ func (a *assertions) pathsOK() bool {
}
default:
a.Fail(JSONPathConversionError(path, expVal, got))
a.terminal = true
return false
}
}
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
10 changes: 0 additions & 10 deletions assertion/json/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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{
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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{
Expand All @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions types/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading