...

Source file src/go.mongodb.org/mongo-driver/mongo/change_stream_test.go

Documentation: go.mongodb.org/mongo-driver/mongo

     1  // Copyright (C) MongoDB, Inc. 2017-present.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"); you may
     4  // not use this file except in compliance with the License. You may obtain
     5  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
     6  
     7  package mongo
     8  
     9  import (
    10  	"testing"
    11  
    12  	"go.mongodb.org/mongo-driver/internal/assert"
    13  )
    14  
    15  func TestChangeStream(t *testing.T) {
    16  	t.Run("nil cursor", func(t *testing.T) {
    17  		cs := &ChangeStream{}
    18  
    19  		id := cs.ID()
    20  		assert.Equal(t, int64(0), id, "expected ID 0, got %v", id)
    21  		assert.False(t, cs.Next(bgCtx), "expected Next to return false, got true")
    22  		err := cs.Decode(nil)
    23  		assert.Equal(t, ErrNilCursor, err, "expected error %v, got %v", ErrNilCursor, err)
    24  		err = cs.Err()
    25  		assert.Nil(t, err, "change stream error: %v", err)
    26  		err = cs.Close(bgCtx)
    27  		assert.Nil(t, err, "Close error: %v", err)
    28  	})
    29  }
    30  

View as plain text