Skip to content

Commit

Permalink
use local lexicon json for unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Dec 20, 2024
1 parent 22eb6a0 commit 0743451
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
44 changes: 44 additions & 0 deletions data/dbs_lexicon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[
{
"name": "file",
"patterns": [
"^/([A-Za-z0-9._\\-/])+/([A-Za-z0-9._\\-])+(.root|.png|.tiff|.tif|.jpeg|jpg|.dat|.txt|.dlog|.mcs|.json|.nx(.xz){0,1})$"
],
"length": 500
},
{
"name": "did",
"patterns": [
"^/[a-z]+=[a-zA-Z0-9\\-\\._\\,]+(/[a-z]+=[a-zA-Z0-9\\-\\._\\,]+)+",
".*unittest.*"
],
"length": 301
},
{
"name": "modify_by",
"patterns": [
"^[a-zA-Z0-9/%*][a-zA-Z0-9/\\.\\-_%*/#]*$",
"^/[a-zA-Z][a-zA-Z0-9/\\=\\s()\\']*\\=[a-zA-Z0-9/\\=\\.\\-_/#:\\s\\']*$",
"^[a-zA-Z0-9/][a-zA-Z0-9/\\.\\-_\\']*$",
"^[a-zA-Z0-9/][a-zA-Z0-9/\\.\\-_]*@[a-zA-Z0-9/][a-zA-Z0-9/\\.\\-_]*$"
],
"length": -1
},
{
"name": "create_by",
"patterns": [
"^[a-zA-Z0-9/%*][a-zA-Z0-9/\\.\\-_%*/#]*$",
"^/[a-zA-Z][a-zA-Z0-9/\\=\\s()\\']*\\=[a-zA-Z0-9/\\=\\.\\-_/#:\\s\\']*$",
"^[a-zA-Z0-9/][a-zA-Z0-9/\\.\\-_\\']*$",
"^[a-zA-Z0-9/][a-zA-Z0-9/\\.\\-_]*@[a-zA-Z0-9/][a-zA-Z0-9/\\.\\-_]*$"
],
"length": -1
},
{
"name": "dataset_id",
"patterns": [
"\\d+"
],
"length": -1
}
]
8 changes: 7 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ func initDBS(dryRun bool, dburi string) *sql.DB {
log.Fatal("unable to get current working dir")
}
// load Lexicon patterns
lexPatterns, err := lexicon.LoadPatterns(srvConfig.Config.DataBookkeeping.LexiconFile)
var lexPatterns map[string]lexicon.LexiconPattern
if srvConfig.Config.DataBookkeeping.LexiconFile != "" {
lexPatterns, err = lexicon.LoadPatterns(srvConfig.Config.DataBookkeeping.LexiconFile)
} else {
// use for unit test in github
lexPatterns, err = lexicon.LoadPatterns("data/dbs_lexicon.json")
}
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 0743451

Please sign in to comment.