Skip to content

Commit bf09441

Browse files
Add NotEmpty to internal assertions
1 parent c687f04 commit bf09441

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

internal/assert/assertions.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,3 +1073,20 @@ func buildErrorChainString(err error) string {
10731073
}
10741074
return chain
10751075
}
1076+
1077+
// NotEmpty asserts that the specified object is NOT [Empty].
1078+
//
1079+
// if assert.NotEmpty(t, obj) {
1080+
// assert.Equal(t, "two", obj[1])
1081+
// }
1082+
func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
1083+
pass := !isEmpty(object)
1084+
if !pass {
1085+
if h, ok := t.(tHelper); ok {
1086+
h.Helper()
1087+
}
1088+
Fail(t, fmt.Sprintf("Should NOT be empty, but was %v", object), msgAndArgs...)
1089+
}
1090+
1091+
return pass
1092+
}

internal/cmd/testatlas/atlas_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import (
1818
"testing"
1919
"time"
2020

21-
"github.com/stretchr/testify/assert"
22-
"github.com/stretchr/testify/require"
2321
"go.mongodb.org/mongo-driver/v2/bson"
22+
"go.mongodb.org/mongo-driver/v2/internal/assert"
2423
"go.mongodb.org/mongo-driver/v2/internal/handshake"
24+
"go.mongodb.org/mongo-driver/v2/internal/require"
2525
"go.mongodb.org/mongo-driver/v2/mongo"
2626
"go.mongodb.org/mongo-driver/v2/mongo/options"
2727
)

0 commit comments

Comments
 (0)