diff --git a/tools/certs/run.go b/tools/certs/run.go index f0f05d7..78f302c 100644 --- a/tools/certs/run.go +++ b/tools/certs/run.go @@ -7,7 +7,7 @@ import ( "time" ) -func run() error { +func Run() error { ctx := context.Background() // Choose DB implementation here (Mongo or SQLite) db, err := setupMongoCertDb() diff --git a/tools/tpps/parse.go b/tools/tpps/parse.go index 4294634..dfd9a5c 100644 --- a/tools/tpps/parse.go +++ b/tools/tpps/parse.go @@ -414,7 +414,7 @@ func parseRegistry() (<-chan models.TPP, error) { return res, nil } -func saveTPPs(db Db, out <-chan models.TPP) error { +func saveTPPs(dbImpl db, out <-chan models.TPP) error { batchSize := 1000 batch := make([]models.TPP, 0, batchSize) idx := 0 @@ -422,7 +422,7 @@ func saveTPPs(db Db, out <-chan models.TPP) error { idx += 1 batch = append(batch, tpp) if idx == batchSize { - err := db.SaveTPPs(context.TODO(), "tpps", batch) + err := dbImpl.SaveTPPs(context.TODO(), "tpps", batch) if err != nil { return err } @@ -431,7 +431,7 @@ func saveTPPs(db Db, out <-chan models.TPP) error { } } if len(batch) > 0 { - err := db.SaveTPPs(context.TODO(), "tpps", batch) + err := dbImpl.SaveTPPs(context.TODO(), "tpps", batch) if err != nil { return err } diff --git a/tools/tpps/run.go b/tools/tpps/run.go index 153595e..c2d85d3 100644 --- a/tools/tpps/run.go +++ b/tools/tpps/run.go @@ -6,12 +6,12 @@ import ( "github.com/botsman/tppVerifier/app/models" ) -type Db interface { +type db interface { SaveTPPs(ctx context.Context, collection string, tpp []models.TPP) error Disconnect(ctx context.Context) error } -func run() error { +func Run() error { // Download and parse the registry // populate DB // 1. Download metadata at https://euclid.eba.europa.eu/register/api/filemetadata?t=1737374419184