Fredrik Nylén
Fredrik Nylén

Reputation: 577

Testing of IO return value

I have a statement that I need to check the return value of:

> let a = tRunUmeQuery (selectByCount "Word" "Acoustic" "=" ((toInteger 1):[]) Strict)  testdb
> :t a 
a :: IO [[SqlValue]]

So, I would like to make sure that a is a list with a length of exactly 6 (IO 6 then).

> fmap length a
6

What would a testCase that checks this look like?

Upvotes: 0

Views: 61

Answers (1)

Fredrik Nylén
Fredrik Nylén

Reputation: 577

Sorry, the solution was not that complicated (I just managed to make it complicated in my head).

ucg :: TestTree
ucg = testGroup "selectByCount" 
    [ testCase "2 Words dominated by exactly 1 Acoustic" $ do 
        r <- fmap length  $ tRunUmeQuery (selectByCount "Word" "Acoustic" "=" ((toInteger 1):[]) Strict) testdb  
        assertEqual "selectByCount: 1 Acoustic in Word" 6 r
    ]

This TestGroup works just fine.

Upvotes: 1

Related Questions