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 7package mongo 8 9import ( 10 "testing" 11 12 "go.mongodb.org/mongo-driver/internal/testutil/assert" 13) 14 15func 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