options_test.go 612 B

123456789101112131415161718192021222324252627
  1. package mon
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/stretchr/testify/assert"
  6. mopt "go.mongodb.org/mongo-driver/mongo/options"
  7. )
  8. func TestSetSlowThreshold(t *testing.T) {
  9. assert.Equal(t, defaultSlowThreshold, slowThreshold.Load())
  10. SetSlowThreshold(time.Second)
  11. assert.Equal(t, time.Second, slowThreshold.Load())
  12. }
  13. func Test_defaultTimeoutOption(t *testing.T) {
  14. opts := mopt.Client()
  15. defaultTimeoutOption()(opts)
  16. assert.Equal(t, defaultTimeout, *opts.Timeout)
  17. }
  18. func TestWithTimeout(t *testing.T) {
  19. opts := mopt.Client()
  20. WithTimeout(time.Second)(opts)
  21. assert.Equal(t, time.Second, *opts.Timeout)
  22. }