mirror of
https://github.com/aelve/guide.git
synced 2024-12-23 12:52:31 +03:00
Remove temp tests (#364)
This commit is contained in:
parent
593cb30fc5
commit
c259052b6d
@ -20,16 +20,13 @@ import Imports
|
|||||||
|
|
||||||
import Hasql.Statement (Statement (..))
|
import Hasql.Statement (Statement (..))
|
||||||
import Hasql.Transaction (Transaction)
|
import Hasql.Transaction (Transaction)
|
||||||
import Hasql.Transaction.Sessions (Mode (..))
|
|
||||||
import Named
|
import Named
|
||||||
import Text.RawString.QQ (r)
|
import Text.RawString.QQ (r)
|
||||||
|
|
||||||
import qualified Hasql.Decoders as HD
|
import qualified Hasql.Decoders as HD
|
||||||
import qualified Hasql.Transaction as HT
|
import qualified Hasql.Transaction as HT
|
||||||
|
|
||||||
import Guide.Database.Connection (connect, runTransactionExceptT)
|
|
||||||
import Guide.Database.Convert
|
import Guide.Database.Convert
|
||||||
import Guide.Database.Get
|
|
||||||
import Guide.Database.Set
|
import Guide.Database.Set
|
||||||
import Guide.Database.Types
|
import Guide.Database.Types
|
||||||
import Guide.Types.Core (Category (..), CategoryStatus (..), Item (..), Trait (..), TraitType (..), ItemSection)
|
import Guide.Types.Core (Category (..), CategoryStatus (..), Item (..), Trait (..), TraitType (..), ItemSection)
|
||||||
@ -174,49 +171,3 @@ addTrait itemId traitId traitType (arg #content -> content) = do
|
|||||||
TraitTypeCon ->
|
TraitTypeCon ->
|
||||||
modifyItemRow itemId $
|
modifyItemRow itemId $
|
||||||
_itemRowConsOrder %~ (++ [traitId])
|
_itemRowConsOrder %~ (++ [traitId])
|
||||||
|
|
||||||
|
|
||||||
-- Sandbox
|
|
||||||
|
|
||||||
-- Test add functions
|
|
||||||
testAdd :: IO ()
|
|
||||||
testAdd = do
|
|
||||||
conn <- connect
|
|
||||||
time <- getCurrentTime
|
|
||||||
runTransactionExceptT conn Write (addCategory "category1111" (#title "addedCat") (#group "groupCat") (#created time) (#status CategoryWIP) (#enabledSections mempty))
|
|
||||||
cat <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
print cat
|
|
||||||
|
|
||||||
runTransactionExceptT conn Write (addItem "category1111" "item11112222" (#name "addedItem") (#created time))
|
|
||||||
item1 <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
print item1
|
|
||||||
runTransactionExceptT conn Write (addItem "category1111" "item22223333" (#name "addedItem") (#created time))
|
|
||||||
item2 <- runTransactionExceptT conn Read (getItemRow "item22223333")
|
|
||||||
print item2
|
|
||||||
|
|
||||||
|
|
||||||
runTransactionExceptT conn Write (addTrait "item11112222" "traitPro1111" TraitTypePro (#content "content Pro 1"))
|
|
||||||
traitP11 <- runTransactionExceptT conn Read (getTraitRowMaybe "traitPro1111")
|
|
||||||
print traitP11
|
|
||||||
runTransactionExceptT conn Write (addTrait "item11112222" "traitPro1122" TraitTypePro (#content "content Pro 2"))
|
|
||||||
traitP12 <- runTransactionExceptT conn Read (getTraitRowMaybe "traitPro1122")
|
|
||||||
print traitP12
|
|
||||||
runTransactionExceptT conn Write (addTrait "item11112222" "traitCon1111" TraitTypeCon (#content "content Con 1"))
|
|
||||||
traitC11 <- runTransactionExceptT conn Read (getTraitRowMaybe "traitCon1111")
|
|
||||||
print traitC11
|
|
||||||
runTransactionExceptT conn Write (addTrait "item11112222" "traitCon1122" TraitTypeCon (#content "content Con 2"))
|
|
||||||
traitC12 <- runTransactionExceptT conn Read (getTraitRowMaybe "traitCon1122")
|
|
||||||
print traitC12
|
|
||||||
|
|
||||||
runTransactionExceptT conn Write (addTrait "item22223333" "traitPro2222" TraitTypePro (#content "content Pro 1"))
|
|
||||||
traitP21 <- runTransactionExceptT conn Read (getTraitRowMaybe "traitPro2222")
|
|
||||||
print traitP21
|
|
||||||
runTransactionExceptT conn Write (addTrait "item22223333" "traitPro2233" TraitTypePro (#content "content Pro 2"))
|
|
||||||
traitP22 <- runTransactionExceptT conn Read (getTraitRowMaybe "traitPro2233")
|
|
||||||
print traitP22
|
|
||||||
runTransactionExceptT conn Write (addTrait "item22223333" "traitCon2222" TraitTypeCon (#content "content Con 1"))
|
|
||||||
traitC21 <- runTransactionExceptT conn Read (getTraitRowMaybe "traitCon2222")
|
|
||||||
print traitC21
|
|
||||||
runTransactionExceptT conn Write (addTrait "item22223333" "traitCon2233" TraitTypeCon (#content "content Con 2"))
|
|
||||||
traitC22 <- runTransactionExceptT conn Read (getTraitRowMaybe "traitCon2233")
|
|
||||||
print traitC22
|
|
||||||
|
@ -37,14 +37,12 @@ import Imports
|
|||||||
import Contravariant.Extras.Contrazip (contrazip2)
|
import Contravariant.Extras.Contrazip (contrazip2)
|
||||||
import Hasql.Statement (Statement (..))
|
import Hasql.Statement (Statement (..))
|
||||||
import Hasql.Transaction (Transaction)
|
import Hasql.Transaction (Transaction)
|
||||||
import Hasql.Transaction.Sessions (Mode (Read))
|
|
||||||
import Text.RawString.QQ (r)
|
import Text.RawString.QQ (r)
|
||||||
|
|
||||||
import qualified Hasql.Decoders as HD
|
import qualified Hasql.Decoders as HD
|
||||||
import qualified Hasql.Encoders as HE
|
import qualified Hasql.Encoders as HE
|
||||||
import qualified Hasql.Transaction as HT
|
import qualified Hasql.Transaction as HT
|
||||||
|
|
||||||
import Guide.Database.Connection (connect, runTransactionExceptT)
|
|
||||||
import Guide.Database.Convert
|
import Guide.Database.Convert
|
||||||
import Guide.Database.Types
|
import Guide.Database.Types
|
||||||
import Guide.Types.Core (Category (..), Item (..), Trait (..), TraitType (..))
|
import Guide.Types.Core (Category (..), Item (..), Trait (..), TraitType (..))
|
||||||
@ -301,38 +299,3 @@ getCategoryRows :: ExceptT DatabaseError Transaction [CategoryRow]
|
|||||||
getCategoryRows = do
|
getCategoryRows = do
|
||||||
catIds <- getCategoryIds
|
catIds <- getCategoryIds
|
||||||
traverse getCategoryRow catIds
|
traverse getCategoryRow catIds
|
||||||
|
|
||||||
|
|
||||||
-- Sandbox
|
|
||||||
|
|
||||||
-- | Just to test queries
|
|
||||||
getTest :: IO ()
|
|
||||||
getTest = do
|
|
||||||
conn <- connect
|
|
||||||
-- mTrait <- runTransactionExceptT conn Read (getTraitRowMaybe "trait1112222")
|
|
||||||
-- print mTrait
|
|
||||||
-- traits <- runTransactionExceptT conn Read $
|
|
||||||
-- getTraitRowsByItem "item11112222" (#deleted False) Pro
|
|
||||||
-- print traits
|
|
||||||
-- mItem <- runTransactionExceptT conn Read (getItemRowMaybe "item11112222")
|
|
||||||
-- print mItem
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print item
|
|
||||||
-- -- wrong uid
|
|
||||||
-- -- itemErr <- runTransactionExceptT conn Read (getItemByItemId "wrong1234567")
|
|
||||||
-- -- print itemErr
|
|
||||||
-- items <- runTransactionExceptT conn Read $
|
|
||||||
-- getItemsByCategory "category1111" (#deleted False)
|
|
||||||
-- print items
|
|
||||||
-- catM <- runTransactionExceptT conn Read (getCategoryRowMaybe "category1111")
|
|
||||||
-- print catM
|
|
||||||
|
|
||||||
cat <- runTransactionExceptT conn Read (getCategoryRowMaybe $ Uid "category1111" )
|
|
||||||
print cat
|
|
||||||
|
|
||||||
-- mCatId <- runTransactionExceptT conn Read (getCategoryIdByItemMaybe "item11112222")
|
|
||||||
-- print mCatId
|
|
||||||
-- catIds <- runTransactionExceptT conn Read getCategoryIds
|
|
||||||
-- print catIds
|
|
||||||
-- cats <- runTransactionExceptT conn Read getCategoryRows
|
|
||||||
-- print cats
|
|
||||||
|
@ -351,136 +351,3 @@ deleteTrait traitId = do
|
|||||||
TraitTypeCon ->
|
TraitTypeCon ->
|
||||||
modifyItemRow itemId $
|
modifyItemRow itemId $
|
||||||
_itemRowConsOrder %~ delete traitId
|
_itemRowConsOrder %~ delete traitId
|
||||||
|
|
||||||
-- Sandbox
|
|
||||||
|
|
||||||
-- Test add functions
|
|
||||||
testSet :: IO ()
|
|
||||||
testSet = do
|
|
||||||
undefined
|
|
||||||
-- conn <- connect
|
|
||||||
-- cat <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
-- print $ _categoryTitle cat
|
|
||||||
-- runTransactionExceptT conn Write (setCategoryTitle "category1111" "addedCatNew")
|
|
||||||
-- cat' <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
-- print $ _categoryTitle cat'
|
|
||||||
|
|
||||||
-- cat <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
-- print $ _categoryGroup_ cat
|
|
||||||
-- runTransactionExceptT conn Write (setCategoryGroup "category1111" "groupNew2")
|
|
||||||
-- cat' <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
-- print $ _categoryGroup_ cat'
|
|
||||||
|
|
||||||
-- cat <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
-- print $ _categoryNotes cat
|
|
||||||
-- runTransactionExceptT conn Write (setCategoryNotes "category1111" "new note")
|
|
||||||
-- cat' <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
-- print $ _categoryNotes cat'
|
|
||||||
|
|
||||||
-- cat <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
-- print $ _categoryStatus cat
|
|
||||||
-- runTransactionExceptT conn Write (setCategoryStatus "category1111" CategoryStub)
|
|
||||||
-- cat' <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
-- print $ _categoryStatus cat'
|
|
||||||
|
|
||||||
-- cat <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
-- print $ _categoryEnabledSections cat
|
|
||||||
-- runTransactionExceptT conn Write
|
|
||||||
-- (setCategoryEnabledSections "category1111"
|
|
||||||
-- (Set.fromList [ItemProsConsSection, ItemNotesSection])
|
|
||||||
-- (Set.fromList [ItemEcosystemSection]))
|
|
||||||
-- cat' <- runTransactionExceptT conn Read (getCategoryRow "category1111")
|
|
||||||
-- print $ _categoryEnabledSections cat'
|
|
||||||
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemName item
|
|
||||||
-- runTransactionExceptT conn Write (setItemName "item11112222" (#name "new note"))
|
|
||||||
-- item' <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemName item'
|
|
||||||
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemLink item
|
|
||||||
-- runTransactionExceptT conn Write (setItemLink "item11112222" (#link "ya.ru"))
|
|
||||||
-- item' <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemLink item'
|
|
||||||
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemLink item
|
|
||||||
-- runTransactionExceptT conn Write (setItemLink "item11112222" ! defaults)
|
|
||||||
-- item' <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemLink item'
|
|
||||||
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemHackage item
|
|
||||||
-- runTransactionExceptT conn Write (setItemHackage "item11112222" ! #hackage "hello")
|
|
||||||
-- item' <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemHackage item'
|
|
||||||
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemSummary item
|
|
||||||
-- runTransactionExceptT conn Write (setItemSummary "item11112222" ! #summary "hello, people!")
|
|
||||||
-- item' <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemSummary item'
|
|
||||||
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemNotes item
|
|
||||||
-- runTransactionExceptT conn Write (setItemNotes "item11112222" ! #notes "hello, people with notes!")
|
|
||||||
-- item' <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemNotes item'
|
|
||||||
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemEcosystem item
|
|
||||||
-- runTransactionExceptT conn Write (setItemEcosystem "item11112222" ! #ecosystem "Export ENV")
|
|
||||||
-- item' <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print $ _itemEcosystem item'
|
|
||||||
|
|
||||||
-- Mark item 'deleted' and check it if it deleted from items_order list
|
|
||||||
-- runTransactionExceptT conn Write (setItemDeleted "item11112222" ! #deleted False)
|
|
||||||
|
|
||||||
|
|
||||||
-- trait <- runTransactionExceptT conn Read (getTraitRowMaybe "trait1112222")
|
|
||||||
-- print trait
|
|
||||||
-- runTransactionExceptT conn Write (setTraitContent "trait1112222" ! #content "all pro")
|
|
||||||
-- trait' <- runTransactionExceptT conn Read (getTraitRowMaybe "trait1112222")
|
|
||||||
-- print trait'
|
|
||||||
|
|
||||||
-- trait <- runTransactionExceptT conn Read (getItemRowMaybe "item11112222")
|
|
||||||
-- print trait
|
|
||||||
-- runTransactionExceptT conn Write (setTraitDeleted "traitPro1122" ! #deleted False)
|
|
||||||
-- trait' <- runTransactionExceptT conn Read (getItemRowMaybe "item11112222")
|
|
||||||
-- print trait'
|
|
||||||
|
|
||||||
-- Move Trait
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRowMaybe "item11112222")
|
|
||||||
-- print item
|
|
||||||
-- runTransactionExceptT conn Write (moveTrait "traitCon1122" MoveUp)
|
|
||||||
-- item' <- runTransactionExceptT conn Read (getItemRowMaybe "item11112222")
|
|
||||||
-- print item'
|
|
||||||
|
|
||||||
-- Delete trait
|
|
||||||
-- trait <- runTransactionExceptT conn Read (getTraitRowMaybe "trait1112222")
|
|
||||||
-- print trait
|
|
||||||
-- runTransactionExceptT conn Write (deleteTrait "trait1112222")
|
|
||||||
-- trait' <- runTransactionExceptT conn Read (getTraitRowMaybe "trait1112222")
|
|
||||||
-- print trait'
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRow "item11112222")
|
|
||||||
-- print item
|
|
||||||
|
|
||||||
-- Delete item
|
|
||||||
-- item <- runTransactionExceptT conn Read (getItemRowMaybe "item11112222")
|
|
||||||
-- print item
|
|
||||||
-- runTransactionExceptT conn Write (deleteItem "item11112222")
|
|
||||||
-- item' <- runTransactionExceptT conn Read (getItemRowMaybe "item11112222")
|
|
||||||
-- print item'
|
|
||||||
|
|
||||||
-- Delete Category
|
|
||||||
-- cat <- runTransactionExceptT conn Read (getCategoryRowMaybe "category1111")
|
|
||||||
-- print cat
|
|
||||||
-- runTransactionExceptT conn Write (deleteCategory "category1111")
|
|
||||||
-- cat' <- runTransactionExceptT conn Read (getCategoryRowMaybe "category1111")
|
|
||||||
-- print cat'
|
|
||||||
|
|
||||||
-- Move Item
|
|
||||||
-- cat' <- runTransactionExceptT conn Read (getCategoryRowMaybe "category1111")
|
|
||||||
-- print cat'
|
|
||||||
-- runTransactionExceptT conn Write (moveItem "item22223333" ! #direction False)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user