github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/documents/mongodb_test.go (about) 1 package documents 2 3 import ( 4 "reflect" 5 "testing" 6 7 "go.mongodb.org/mongo-driver/bson" 8 "go.mongodb.org/mongo-driver/mongo" 9 ) 10 11 func TestDocDB_ConnectMongoDB(t *testing.T) { 12 tests := []struct { 13 name string 14 doc *DocDB 15 want *DocDB 16 wantErr bool 17 }{ 18 // TODO: Add test cases. 19 } 20 for _, tt := range tests { 21 t.Run(tt.name, func(t *testing.T) { 22 got, err := tt.doc.ConnectMongoDB() 23 if (err != nil) != tt.wantErr { 24 t.Errorf("DocDB.ConnectMongoDB() error = %v, wantErr %v", err, tt.wantErr) 25 return 26 } 27 if !reflect.DeepEqual(got, tt.want) { 28 t.Errorf("DocDB.ConnectMongoDB() = %v, want %v", got, tt.want) 29 } 30 }) 31 } 32 } 33 34 func TestDocDB_QueryCollection(t *testing.T) { 35 type args struct { 36 collectionname string 37 filter bson.M 38 projection bson.M 39 } 40 tests := []struct { 41 name string 42 doc *DocDB 43 args args 44 want []bson.M 45 wantErr bool 46 }{ 47 // TODO: Add test cases. 48 } 49 for _, tt := range tests { 50 t.Run(tt.name, func(t *testing.T) { 51 got, err := tt.doc.QueryCollection(tt.args.collectionname, tt.args.filter, tt.args.projection) 52 if (err != nil) != tt.wantErr { 53 t.Errorf("DocDB.QueryCollection() error = %v, wantErr %v", err, tt.wantErr) 54 return 55 } 56 if !reflect.DeepEqual(got, tt.want) { 57 t.Errorf("DocDB.QueryCollection() = %v, want %v", got, tt.want) 58 } 59 }) 60 } 61 } 62 63 func TestDocDB_GetDefaultItembyName(t *testing.T) { 64 type args struct { 65 collectionname string 66 name string 67 } 68 tests := []struct { 69 name string 70 doc *DocDB 71 args args 72 want bson.M 73 wantErr bool 74 }{ 75 // TODO: Add test cases. 76 } 77 for _, tt := range tests { 78 t.Run(tt.name, func(t *testing.T) { 79 got, err := tt.doc.GetDefaultItembyName(tt.args.collectionname, tt.args.name) 80 if (err != nil) != tt.wantErr { 81 t.Errorf("DocDB.GetDefaultItembyName() error = %v, wantErr %v", err, tt.wantErr) 82 return 83 } 84 if !reflect.DeepEqual(got, tt.want) { 85 t.Errorf("DocDB.GetDefaultItembyName() = %v, want %v", got, tt.want) 86 } 87 }) 88 } 89 } 90 91 func TestDocDB_GetItembyID(t *testing.T) { 92 type args struct { 93 collectionname string 94 id string 95 } 96 tests := []struct { 97 name string 98 doc *DocDB 99 args args 100 want bson.M 101 wantErr bool 102 }{ 103 // TODO: Add test cases. 104 } 105 for _, tt := range tests { 106 t.Run(tt.name, func(t *testing.T) { 107 got, err := tt.doc.GetItembyID(tt.args.collectionname, tt.args.id) 108 if (err != nil) != tt.wantErr { 109 t.Errorf("DocDB.GetItembyID() error = %v, wantErr %v", err, tt.wantErr) 110 return 111 } 112 if !reflect.DeepEqual(got, tt.want) { 113 t.Errorf("DocDB.GetItembyID() = %v, want %v", got, tt.want) 114 } 115 }) 116 } 117 } 118 119 func TestDocDB_UpdateCollection(t *testing.T) { 120 type args struct { 121 collectionname string 122 filter bson.M 123 update bson.M 124 idata interface{} 125 } 126 tests := []struct { 127 name string 128 doc *DocDB 129 args args 130 wantErr bool 131 }{ 132 // TODO: Add test cases. 133 } 134 for _, tt := range tests { 135 t.Run(tt.name, func(t *testing.T) { 136 if err := tt.doc.UpdateCollection(tt.args.collectionname, tt.args.filter, tt.args.update, tt.args.idata); (err != nil) != tt.wantErr { 137 t.Errorf("DocDB.UpdateCollection() error = %v, wantErr %v", err, tt.wantErr) 138 } 139 }) 140 } 141 } 142 143 func TestDocDB_InsertCollection(t *testing.T) { 144 type args struct { 145 collectionname string 146 idata interface{} 147 } 148 tests := []struct { 149 name string 150 doc *DocDB 151 args args 152 want *mongo.InsertOneResult 153 wantErr bool 154 }{ 155 // TODO: Add test cases. 156 } 157 for _, tt := range tests { 158 t.Run(tt.name, func(t *testing.T) { 159 got, err := tt.doc.InsertCollection(tt.args.collectionname, tt.args.idata) 160 if (err != nil) != tt.wantErr { 161 t.Errorf("DocDB.InsertCollection() error = %v, wantErr %v", err, tt.wantErr) 162 return 163 } 164 if !reflect.DeepEqual(got, tt.want) { 165 t.Errorf("DocDB.InsertCollection() = %v, want %v", got, tt.want) 166 } 167 }) 168 } 169 } 170 171 func TestDocDB_DeleteItemFromCollection(t *testing.T) { 172 type args struct { 173 collectionname string 174 documentid string 175 } 176 tests := []struct { 177 name string 178 doc *DocDB 179 args args 180 wantErr bool 181 }{ 182 // TODO: Add test cases. 183 } 184 for _, tt := range tests { 185 t.Run(tt.name, func(t *testing.T) { 186 if err := tt.doc.DeleteItemFromCollection(tt.args.collectionname, tt.args.documentid); (err != nil) != tt.wantErr { 187 t.Errorf("DocDB.DeleteItemFromCollection() error = %v, wantErr %v", err, tt.wantErr) 188 } 189 }) 190 } 191 } 192 193 func TestDocDB_convertToBsonM(t *testing.T) { 194 type args struct { 195 data interface{} 196 } 197 tests := []struct { 198 name string 199 doc *DocDB 200 args args 201 want bson.M 202 wantErr bool 203 }{ 204 // TODO: Add test cases. 205 } 206 for _, tt := range tests { 207 t.Run(tt.name, func(t *testing.T) { 208 got, err := tt.doc.convertToBsonM(tt.args.data) 209 if (err != nil) != tt.wantErr { 210 t.Errorf("DocDB.convertToBsonM() error = %v, wantErr %v", err, tt.wantErr) 211 return 212 } 213 if !reflect.DeepEqual(got, tt.want) { 214 t.Errorf("DocDB.convertToBsonM() = %v, want %v", got, tt.want) 215 } 216 }) 217 } 218 }