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

Add tests for decimal128 and timestamp #78

Merged
merged 12 commits into from
Feb 4, 2025
Prev Previous commit
Next Next commit
Tweak tests
AlekSi committed Jan 10, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 202632092c84aee858e2bb8de4774af5ff776184
14 changes: 14 additions & 0 deletions wireclient/wireclient_test.go
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ func logger(tb testing.TB) *slog.Logger {
return slog.New(h)
}

// setup waits for FerretDB or MongoDB to start and returns the URI.
func setup(t testing.TB) string {
t.Helper()

@@ -72,10 +73,21 @@ func setup(t testing.TB) string {
uri := os.Getenv("MONGODB_URI")
require.NotEmpty(t, uri, "MONGODB_URI environment variable must be set; set it or run tests with `go test -short`")

ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

conn := ConnectPing(ctx, uri, logger(t))
require.NotNil(t, conn)

err := conn.Close()
require.NoError(t, err)

return uri
}

func TestConn(t *testing.T) {
t.Parallel()

uri := setup(t)

ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
@@ -118,6 +130,8 @@ func TestConn(t *testing.T) {
}

func TestDecimal128(t *testing.T) {
t.Parallel()

uri := setup(t)

d := wirebson.Decimal128{H: 13, L: 42}