@@ -761,6 +761,40 @@ func TestCollectionRevision(t *testing.T) {
761761 }
762762}
763763
764+ // TestCollectionChecksum creates a collection, checks checksum after adding documents.
765+ func TestCollectionChecksum (t * testing.T ) {
766+ c := createClientFromEnv (t , true )
767+ db := ensureDatabase (nil , c , "collection_checksum" , nil , t )
768+ name := "test_collection_checksum"
769+ col , err := db .CreateCollection (nil , name , nil )
770+ require .NoError (t , err )
771+
772+ // create some documents
773+ for i := 0 ; i < 5 ; i ++ {
774+ before , err := col .Checksum (nil , false , false )
775+ require .NoError (t , err )
776+
777+ doc := Book {Title : fmt .Sprintf ("Book %d" , i )}
778+ _ , err = col .CreateDocument (nil , doc )
779+ require .NoError (t , err )
780+
781+ after , err := col .Checksum (nil , false , false )
782+ require .NoError (t , err )
783+ require .NotEqual (t , before .Checksum , after .Checksum )
784+
785+ afterWithRevision , err := col .Checksum (nil , true , false )
786+ require .NoError (t , err )
787+ require .NotEqual (t , before .Checksum , afterWithRevision .Checksum )
788+ require .NotEqual (t , after .Checksum , afterWithRevision .Checksum )
789+
790+ afterWithData , err := col .Checksum (nil , false , true )
791+ require .NoError (t , err )
792+ require .NotEqual (t , before .Checksum , afterWithData .Checksum )
793+ require .NotEqual (t , after .Checksum , afterWithData .Checksum )
794+ require .NotEqual (t , afterWithRevision .Checksum , afterWithData .Checksum )
795+ }
796+ }
797+
764798// TestCollectionStatistics creates a collection, checks statistics after adding documents.
765799func TestCollectionStatistics (t * testing.T ) {
766800 c := createClientFromEnv (t , true )
0 commit comments