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
120
Issues
120
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
a42dca01
Verified
Commit
a42dca01
authored
Oct 27, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tests] simplify nodestory tests
parent
912dcbd7
Pipeline
#5313
failed with stages
in 46 minutes and 11 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
99 deletions
+26
-99
NodeStory.hs
test/Test/Database/Operations/NodeStory.hs
+26
-99
No files found.
test/Test/Database/Operations/NodeStory.hs
View file @
a42dca01
...
@@ -40,13 +40,12 @@ import Test.Database.Types
...
@@ -40,13 +40,12 @@ import Test.Database.Types
import
Test.Hspec.Expectations
import
Test.Hspec.Expectations
import
Test.Tasty.HUnit
import
Test.Tasty.HUnit
commonInitialization
::
TestMonad
(
Gargantext
.
Database
.
Admin
.
Types
.
Node
.
UserId
createListTest
::
TestEnv
->
Assertion
,
Gargantext
.
Database
.
Admin
.
Types
.
Node
.
NodeId
createListTest
env
=
do
,
Gargantext
.
Database
.
Admin
.
Types
.
Node
.
ListId
flip
runReaderT
env
$
runTestMonad
$
do
,
GHC
.
Conc
.
Sync
.
TVar
NodeListStory
)
-- NOTE(adn) We need to create user 'gargantua'(!!) in order
commonInitialization
=
do
-- for 'addDocumentsToHyperCorpus' to work.
let
user
=
UserName
userMaster
let
user
=
UserName
userMaster
parentId
<-
getRootId
user
parentId
<-
getRootId
user
[
corpus
]
<-
getCorporaWithParentId
parentId
[
corpus
]
<-
getCorporaWithParentId
parentId
...
@@ -55,6 +54,17 @@ createListTest env = do
...
@@ -55,6 +54,17 @@ createListTest env = do
userId
<-
getUserId
user
userId
<-
getUserId
user
listId
<-
getOrMkList
corpusId
userId
listId
<-
getOrMkList
corpusId
userId
v
<-
getNodeStoryVar
[
listId
]
pure
$
(
userId
,
corpusId
,
listId
,
v
)
createListTest
::
TestEnv
->
Assertion
createListTest
env
=
do
flip
runReaderT
env
$
runTestMonad
$
do
(
userId
,
corpusId
,
listId
,
_v
)
<-
commonInitialization
listId'
<-
getOrMkList
corpusId
userId
listId'
<-
getOrMkList
corpusId
userId
liftIO
$
listId
`
shouldBe
`
listId'
liftIO
$
listId
`
shouldBe
`
listId'
...
@@ -63,21 +73,10 @@ createListTest env = do
...
@@ -63,21 +73,10 @@ createListTest env = do
queryNodeStoryTest
::
TestEnv
->
Assertion
queryNodeStoryTest
::
TestEnv
->
Assertion
queryNodeStoryTest
env
=
do
queryNodeStoryTest
env
=
do
flip
runReaderT
env
$
runTestMonad
$
do
flip
runReaderT
env
$
runTestMonad
$
do
-- NOTE(adn) We need to create user 'gargantua'(!!) in order
(
_userId
,
_corpusId
,
listId
,
v
)
<-
commonInitialization
-- for 'addDocumentsToHyperCorpus' to work.
let
user
=
UserName
userMaster
parentId
<-
getRootId
user
[
corpus
]
<-
getCorporaWithParentId
parentId
let
corpusId
=
_node_id
corpus
userId
<-
getUserId
user
listId
<-
getOrMkList
corpusId
userId
saveNodeStoryImmediate
saveNodeStoryImmediate
v
<-
getNodeStoryVar
[
listId
]
liftIO
$
do
liftIO
$
do
ns
<-
atomically
$
readTVar
v
ns
<-
atomically
$
readTVar
v
ns
`
shouldBe
`
(
NodeStory
$
Map
.
singleton
listId
ns
`
shouldBe
`
(
NodeStory
$
Map
.
singleton
listId
...
@@ -87,18 +86,7 @@ queryNodeStoryTest env = do
...
@@ -87,18 +86,7 @@ queryNodeStoryTest env = do
insertNewTermsToNodeStoryTest
::
TestEnv
->
Assertion
insertNewTermsToNodeStoryTest
::
TestEnv
->
Assertion
insertNewTermsToNodeStoryTest
env
=
do
insertNewTermsToNodeStoryTest
env
=
do
flip
runReaderT
env
$
runTestMonad
$
do
flip
runReaderT
env
$
runTestMonad
$
do
-- NOTE(adn) We need to create user 'gargantua'(!!) in order
(
_userId
,
_corpusId
,
listId
,
v
)
<-
commonInitialization
-- for 'addDocumentsToHyperCorpus' to work.
let
user
=
UserName
userMaster
parentId
<-
getRootId
user
[
corpus
]
<-
getCorporaWithParentId
parentId
let
corpusId
=
_node_id
corpus
userId
<-
getUserId
user
listId
<-
getOrMkList
corpusId
userId
v
<-
getNodeStoryVar
[
listId
]
let
nre
=
NgramsRepoElement
{
_nre_size
=
1
let
nre
=
NgramsRepoElement
{
_nre_size
=
1
,
_nre_list
=
MapTerm
,
_nre_list
=
MapTerm
...
@@ -115,15 +103,9 @@ insertNewTermsToNodeStoryTest env = do
...
@@ -115,15 +103,9 @@ insertNewTermsToNodeStoryTest env = do
((
initArchive
::
ArchiveList
)
{
_a_state
=
Map
.
singleton
NgramsTerms
nls
}))
((
initArchive
::
ArchiveList
)
{
_a_state
=
Map
.
singleton
NgramsTerms
nls
}))
-- check that the ngrams are in the DB as well
-- check that the ngrams are in the DB as well
ngramsMap
<-
selectNgramsId
[
terms
]
ngramsMap
<-
selectNgramsId
[
terms
]
-- saveNodeStory is called by `setListNgrams`
liftIO
$
(
snd
<$>
Map
.
toList
ngramsMap
)
`
shouldBe
`
[
terms
]
liftIO
$
(
snd
<$>
Map
.
toList
ngramsMap
)
`
shouldBe
`
[
terms
]
-- _ <- insertNgrams [UnsafeNgrams { _ngramsTerms = terms
-- , _ngramsSize = 1 }]
-- Finally, check that node stories are inserted correctly
-- Finally, check that node stories are inserted correctly
-- saveNodeStoryImmediate
dbTerms
<-
runPGSQuery
[
sql
|
dbTerms
<-
runPGSQuery
[
sql
|
SELECT terms
SELECT terms
FROM ngrams
FROM ngrams
...
@@ -136,18 +118,7 @@ insertNewTermsToNodeStoryTest env = do
...
@@ -136,18 +118,7 @@ insertNewTermsToNodeStoryTest env = do
insertNewTermsWithChildrenToNodeStoryTest
::
TestEnv
->
Assertion
insertNewTermsWithChildrenToNodeStoryTest
::
TestEnv
->
Assertion
insertNewTermsWithChildrenToNodeStoryTest
env
=
do
insertNewTermsWithChildrenToNodeStoryTest
env
=
do
flip
runReaderT
env
$
runTestMonad
$
do
flip
runReaderT
env
$
runTestMonad
$
do
-- NOTE(adn) We need to create user 'gargantua'(!!) in order
(
_userId
,
_corpusId
,
listId
,
v
)
<-
commonInitialization
-- for 'addDocumentsToHyperCorpus' to work.
let
user
=
UserName
userMaster
parentId
<-
getRootId
user
[
corpus
]
<-
getCorporaWithParentId
parentId
let
corpusId
=
_node_id
corpus
userId
<-
getUserId
user
listId
<-
getOrMkList
corpusId
userId
v
<-
getNodeStoryVar
[
listId
]
let
tParent
=
NgramsTerm
"hello"
let
tParent
=
NgramsTerm
"hello"
let
tChild
=
NgramsTerm
"world"
let
tChild
=
NgramsTerm
"world"
...
@@ -196,18 +167,7 @@ insertNewTermsWithChildrenToNodeStoryTest env = do
...
@@ -196,18 +167,7 @@ insertNewTermsWithChildrenToNodeStoryTest env = do
insertNodeStoryChildrenWithDifferentNgramsTypeThanParentTest
::
TestEnv
->
Assertion
insertNodeStoryChildrenWithDifferentNgramsTypeThanParentTest
::
TestEnv
->
Assertion
insertNodeStoryChildrenWithDifferentNgramsTypeThanParentTest
env
=
do
insertNodeStoryChildrenWithDifferentNgramsTypeThanParentTest
env
=
do
flip
runReaderT
env
$
runTestMonad
$
do
flip
runReaderT
env
$
runTestMonad
$
do
-- NOTE(adn) We need to create user 'gargantua'(!!) in order
(
_userId
,
_corpusId
,
listId
,
v
)
<-
commonInitialization
-- for 'addDocumentsToHyperCorpus' to work.
let
user
=
UserName
userMaster
parentId
<-
getRootId
user
[
corpus
]
<-
getCorporaWithParentId
parentId
let
corpusId
=
_node_id
corpus
userId
<-
getUserId
user
listId
<-
getOrMkList
corpusId
userId
v
<-
getNodeStoryVar
[
listId
]
let
tParent
=
NgramsTerm
"hello"
let
tParent
=
NgramsTerm
"hello"
let
tChild
=
NgramsTerm
"world"
let
tChild
=
NgramsTerm
"world"
...
@@ -255,18 +215,7 @@ insertNodeStoryChildrenWithDifferentNgramsTypeThanParentTest env = do
...
@@ -255,18 +215,7 @@ insertNodeStoryChildrenWithDifferentNgramsTypeThanParentTest env = do
setListNgramsUpdatesNodeStoryTest
::
TestEnv
->
Assertion
setListNgramsUpdatesNodeStoryTest
::
TestEnv
->
Assertion
setListNgramsUpdatesNodeStoryTest
env
=
do
setListNgramsUpdatesNodeStoryTest
env
=
do
flip
runReaderT
env
$
runTestMonad
$
do
flip
runReaderT
env
$
runTestMonad
$
do
-- NOTE(adn) We need to create user 'gargantua'(!!) in order
(
_userId
,
_corpusId
,
listId
,
v
)
<-
commonInitialization
-- for 'addDocumentsToHyperCorpus' to work.
let
user
=
UserName
userMaster
parentId
<-
getRootId
user
[
corpus
]
<-
getCorporaWithParentId
parentId
let
corpusId
=
_node_id
corpus
userId
<-
getUserId
user
listId
<-
getOrMkList
corpusId
userId
v
<-
getNodeStoryVar
[
listId
]
let
nre
=
NgramsRepoElement
{
_nre_size
=
1
let
nre
=
NgramsRepoElement
{
_nre_size
=
1
,
_nre_list
=
MapTerm
,
_nre_list
=
MapTerm
...
@@ -303,18 +252,7 @@ setListNgramsUpdatesNodeStoryTest env = do
...
@@ -303,18 +252,7 @@ setListNgramsUpdatesNodeStoryTest env = do
setListNgramsUpdatesNodeStoryWithChildrenTest
::
TestEnv
->
Assertion
setListNgramsUpdatesNodeStoryWithChildrenTest
::
TestEnv
->
Assertion
setListNgramsUpdatesNodeStoryWithChildrenTest
env
=
do
setListNgramsUpdatesNodeStoryWithChildrenTest
env
=
do
flip
runReaderT
env
$
runTestMonad
$
do
flip
runReaderT
env
$
runTestMonad
$
do
-- NOTE(adn) We need to create user 'gargantua'(!!) in order
(
_userId
,
_corpusId
,
listId
,
v
)
<-
commonInitialization
-- for 'addDocumentsToHyperCorpus' to work.
let
user
=
UserName
userMaster
parentId
<-
getRootId
user
[
corpus
]
<-
getCorporaWithParentId
parentId
let
corpusId
=
_node_id
corpus
userId
<-
getUserId
user
listId
<-
getOrMkList
corpusId
userId
v
<-
getNodeStoryVar
[
listId
]
let
tParent
=
NgramsTerm
"hello"
let
tParent
=
NgramsTerm
"hello"
let
tChild
=
NgramsTerm
"world"
let
tChild
=
NgramsTerm
"world"
...
@@ -355,18 +293,7 @@ setListNgramsUpdatesNodeStoryWithChildrenTest env = do
...
@@ -355,18 +293,7 @@ setListNgramsUpdatesNodeStoryWithChildrenTest env = do
commitPatchSimpleTest
::
TestEnv
->
Assertion
commitPatchSimpleTest
::
TestEnv
->
Assertion
commitPatchSimpleTest
env
=
do
commitPatchSimpleTest
env
=
do
flip
runReaderT
env
$
runTestMonad
$
do
flip
runReaderT
env
$
runTestMonad
$
do
-- NOTE(adn) We need to create user 'gargantua'(!!) in order
(
_userId
,
_corpusId
,
listId
,
v
)
<-
commonInitialization
-- for 'addDocumentsToHyperCorpus' to work.
let
user
=
UserName
userMaster
parentId
<-
getRootId
user
[
corpus
]
<-
getCorporaWithParentId
parentId
let
corpusId
=
_node_id
corpus
userId
<-
getUserId
user
listId
<-
getOrMkList
corpusId
userId
v
<-
getNodeStoryVar
[
listId
]
-- initially, the node story table is empty
-- initially, the node story table is empty
liftIO
$
do
liftIO
$
do
...
...
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