From 90e9bcf37812e740c9750c40680cdf5da308cbe1 Mon Sep 17 00:00:00 2001 From: pb Date: Wed, 17 Jul 2024 17:19:42 +0200 Subject: [PATCH] improve testing --- mongo/mongo_utils.go | 46 ++++++++++++++++++++++++ tests/config.go | 1 + oclib_conf.json => tests/oclib_conf.json | 0 3 files changed, 47 insertions(+) create mode 100644 mongo/mongo_utils.go create mode 100644 tests/config.go rename oclib_conf.json => tests/oclib_conf.json (100%) diff --git a/mongo/mongo_utils.go b/mongo/mongo_utils.go new file mode 100644 index 0000000..d2972a4 --- /dev/null +++ b/mongo/mongo_utils.go @@ -0,0 +1,46 @@ +package mongo + +import ( + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" +) + +// Will store the created collection object for a faster access +var CollectionMap map[string]*mongo.Collection +var IndexesMap map[string][]mongo.IndexModel + +func init() { + CollectionMap = make(map[string]*mongo.Collection) + IndexesMap = make(map[string][]mongo.IndexModel) + + IndexesMap["data"] = append(IndexesMap["data"], mongo.IndexModel{Keys: bson.D{ + {Key: "description", Value:"text"}, + {Key: "example", Value:"text"}}, + }) + + IndexesMap["datacenter"] = append(IndexesMap["datacenter"], mongo.IndexModel{Keys: bson.D{ + {Key: "description", Value:"text"}, + {Key: "example", Value:"text"}, + {Key: "owner", Value:"text"}}, + }) + + IndexesMap["storage"] = append(IndexesMap["storage"], mongo.IndexModel{Keys: bson.D{ + {Key: "description", Value:"text"}, + {Key: "example", Value:"text"}}, + }) + + IndexesMap["processing"] = append(IndexesMap["processing"], mongo.IndexModel{Keys: bson.D{ + {Key: "description", Value:"text"}, + {Key: "example", Value:"text"}, + {Key: "owner", Value:"text"}, + }, + }) + + IndexesMap["workflow"] = append(IndexesMap["workflow"], mongo.IndexModel{Keys: bson.D{ + {Key: "description", Value:"text"}, + {Key: "example", Value:"text"}, + {Key: "owner", Value:"text"}, + }, + }) + +} \ No newline at end of file diff --git a/tests/config.go b/tests/config.go new file mode 100644 index 0000000..7fdc98f --- /dev/null +++ b/tests/config.go @@ -0,0 +1 @@ +package tests \ No newline at end of file diff --git a/oclib_conf.json b/tests/oclib_conf.json similarity index 100% rename from oclib_conf.json rename to tests/oclib_conf.json