From 586571d6d70f46c7720d609c5b14872a08d52c63 Mon Sep 17 00:00:00 2001 From: Pavel Botsman <11509664+botsman@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:44:39 +0300 Subject: [PATCH 1/2] export run command --- tools/certs/run.go | 2 +- tools/tpps/run.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/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 From 9eeab7479c27dd32b628d2e6a18b27f9f1e3b90f Mon Sep 17 00:00:00 2001 From: Pavel Botsman <11509664+botsman@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:49:01 +0300 Subject: [PATCH 2/2] fix test --- tools/tpps/parse.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 }