File: ReviewDecodeSpec.hs

package info (click to toggle)
haskell-github 0.29-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 944 kB
  • sloc: haskell: 7,744; makefile: 3
file content (25 lines) | stat: -rw-r--r-- 1,030 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell   #-}
module GitHub.ReviewDecodeSpec where

import Data.Aeson         (eitherDecodeStrict)
import Data.Either.Compat (isRight)
import Data.FileEmbed     (embedFile)
import Test.Hspec
       (Spec, describe, it, shouldSatisfy)

import GitHub.Data (Review)

spec :: Spec
spec = do
  describe "PENDING state" $ do
    -- https://docs.github.com/en/rest/reference/pulls#create-a-review-for-a-pull-request
    -- > Pull request reviews created in the PENDING state do not include the submitted_at property in the response.
    it "decodes review when submitted_at is missing" $ do
      let reviewInfo = eitherDecodeStrict $(embedFile "fixtures/pull-request-pending-review.json") :: Either String Review
      reviewInfo `shouldSatisfy` isRight

  describe "Other states" $ do
    it "decodes review" $ do
      let reviewInfo = eitherDecodeStrict $(embedFile "fixtures/pull-request-approved-review.json") :: Either String Review
      reviewInfo `shouldSatisfy` isRight