Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
191
Issues
191
List
Board
Labels
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
b5c9df51
Commit
b5c9df51
authored
Aug 04, 2025
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for loop detection
parent
43191319
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
UpdateList.hs
test/Test/API/UpdateList.hs
+85
-0
No files found.
test/Test/API/UpdateList.hs
View file @
b5c9df51
...
@@ -81,6 +81,7 @@ import Text.Printf (printf)
...
@@ -81,6 +81,7 @@ import Text.Printf (printf)
import
qualified
Data.Text.Encoding
as
TE
import
qualified
Data.Text.Encoding
as
TE
import
qualified
Data.ByteString
as
BIO
import
qualified
Data.ByteString
as
BIO
import
Control.Lens
(
view
)
import
Control.Lens
(
view
)
import
Gargantext.API.Admin.Orchestrator.Types
uploadJSONList
::
LogConfig
uploadJSONList
::
LogConfig
...
@@ -608,6 +609,90 @@ tests = sequential $ aroundAll withTestDBAndPort $ beforeAllWith dbEnvSetup $ do
...
@@ -608,6 +609,90 @@ tests = sequential $ aroundAll withTestDBAndPort $ beforeAllWith dbEnvSetup $ do
let
exportedNgrams2
=
view
v_data
<$>
Map
.
lookup
NgramsTerms
exported2
let
exportedNgrams2
=
view
v_data
<$>
Map
.
lookup
NgramsTerms
exported2
liftIO
$
exportedNgrams
`
shouldBe
`
exportedNgrams2
liftIO
$
exportedNgrams
`
shouldBe
`
exportedNgrams2
-- We test that if we try to import terms which, when merged with the existing,
-- would cause a loop, GGTX is capable of rejecting the request.
it
"refuses to import terms which will lead to a loop"
$
\
(
SpecContext
testEnv
port
app
_
)
->
do
cId
<-
newCorpusForUser
testEnv
"alice"
let
log_cfg
=
(
test_config
testEnv
)
^.
gc_logging
withApplication
app
$
do
withValidLogin
port
"alice"
(
GargPassword
"alice"
)
$
\
clientEnv
token
->
do
-- Import the initial terms
let
(
Right
initialTerms
)
=
JSON
.
eitherDecode
@
NgramsList
$
[
json
|
{
"Authors": {
"version": 1,
"data": {}
},
"Institutes": {
"version": 1,
"data": {}
},
"Sources": {
"version": 1,
"data": {}
},
"NgramsTerms": {
"version": 1,
"data": {
"foo": {
"size": 1,
"list": "MapTerm",
"children": ["bar"]
},
"bar": {
"root": "foo",
"parent": "foo",
"size": 1,
"list": "MapTerm",
"children": [
"quux"
]
},
"quux": {
"size": 1,
"list": "MapTerm",
"children": []
} } } }
|]
listId
<-
uploadJSONListBS
log_cfg
port
token
cId
(
BL
.
toStrict
$
JSON
.
encode
initialTerms
)
clientEnv
let
(
Right
secondBatch
)
=
JSON
.
eitherDecode
@
NgramsList
$
[
json
|
{
"Authors": {
"version": 1,
"data": {}
},
"Institutes": {
"version": 1,
"data": {}
},
"Sources": {
"version": 1,
"data": {}
},
"NgramsTerms": {
"version": 1,
"data": {
"bar": {
"size": 1,
"list": "MapTerm",
"children": ["foo"]
}
} } }
|]
let
params
=
WithJsonFile
{
_wjf_data
=
TE
.
decodeUtf8
(
BL
.
toStrict
$
JSON
.
encode
secondBatch
)
,
_wjf_name
=
"simple_ngrams.json"
}
ji
<-
checkEither
$
liftIO
$
runClientM
(
add_form_to_list
token
listId
params
)
clientEnv
ji'
<-
pollUntilWorkFinished
log_cfg
port
ji
-- Unfortunately we don't have a better way then to match on the stringified exception, sigh.
case
_scst_events
ji'
of
Just
[
ScraperEvent
{
..
}]
|
Just
msg
<-
_scev_message
->
liftIO
$
msg
`
shouldSatisfy
`
\
txt
->
"BFE_loop_detected"
`
T
.
isInfixOf
`
txt
|
otherwise
->
fail
"No suitable message in ScraperEvent."
_
->
fail
"Expected job to fail, but it didn't"
createDocsList
::
FilePath
createDocsList
::
FilePath
->
TestEnv
->
TestEnv
->
Int
->
Int
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment