2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE OverloadedStrings #-}
4{-# LANGUAGE RecordWildCards #-}
5{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE TypeOperators #-}
7{-# OPTIONS_GHC -fno-warn-orphans #-}
8#if __GLASGOW_HASKELL__ < 800
9{-# OPTIONS_GHC -fcontext-stack=100 #-}
11#if __GLASGOW_HASKELL__ >= 802
12{-# LANGUAGE MonoLocalBinds #-}
21import qualified Test.Aggregation as Aggregation
22import qualified Test.BulkAPI as Bulk
23import qualified Test.Documents as Documents
24import qualified Test.Highlights as Highlights
25import qualified Test.Indices as Indices
26import qualified Test.JSON as JSON
27import qualified Test.Query as Query
28import qualified Test.Script as Script
29import qualified Test.Snapshots as Snapshots
30import qualified Test.Sorting as Sorting
31import qualified Test.SourceFiltering as SourceFiltering
32import qualified Test.Suggest as Suggest
33import qualified Test.Templates as Templates
51 describe "error parsing" $ do
52 it "can parse EsErrors for < 2.0" $ when' (atmost es16) $ withTestEnv $ do
53 res <- getDocument (IndexName "bogus") (MappingName "also_bogus") (DocId "bogus_as_well")
54 let errorResp = eitherDecode (responseBody res)
55 liftIO (errorResp `shouldBe` Right (EsError 404 "IndexMissingException[[bogus] missing]"))
57 it "can parse EsErrors for >= 2.0" $ when' (atleast es20) $ withTestEnv $ do
58 res <- getDocument (IndexName "bogus") (MappingName "also_bogus") (DocId "bogus_as_well")
59 let errorResp = eitherDecode (responseBody res)
60 liftIO (errorResp `shouldBe` Right (EsError 404 "no such index"))
62 describe "Monoid (SearchHits a)" $
63 prop "abides the monoid laws" $ eq $
64 prop_Monoid (T :: T (SearchHits ()))
66 describe "mkDocVersion" $
67 prop "can never construct an out of range docVersion" $ \i ->
68 let res = mkDocVersion i
70 Nothing -> property True
71 Just dv -> (dv >= minBound) .&&.
73 docVersionNumber dv === i
75 describe "getNodesInfo" $
76 it "fetches the responding node when LocalNode is used" $ withTestEnv $ do
77 res <- getNodesInfo LocalNode
79 -- This is really just a smoke test for response
80 -- parsing. Node info is so variable, there's not much I can
82 Right NodesInfo {..} -> length nodesInfo `shouldBe` 1
83 Left e -> expectationFailure ("Expected NodesInfo but got " <> show e)
85 describe "getNodesStats" $
86 it "fetches the responding node when LocalNode is used" $ withTestEnv $ do
87 res <- getNodesStats LocalNode
89 -- This is really just a smoke test for response
90 -- parsing. Node stats is so variable, there's not much I can
92 Right NodesStats {..} -> length nodesStats `shouldBe` 1
93 Left e -> expectationFailure ("Expected NodesStats but got " <> show e)
95 describe "Enum DocVersion" $
96 it "follows the laws of Enum, Bounded" $ do
97 evaluate (succ maxBound :: DocVersion) `shouldThrow` anyErrorCall
98 evaluate (pred minBound :: DocVersion) `shouldThrow` anyErrorCall
99 evaluate (toEnum 0 :: DocVersion) `shouldThrow` anyErrorCall
100 evaluate (toEnum 9200000000000000001 :: DocVersion) `shouldThrow` anyErrorCall
101 enumFrom (pred maxBound :: DocVersion) `shouldBe` [pred maxBound, maxBound]
102 enumFrom (pred maxBound :: DocVersion) `shouldBe` [pred maxBound, maxBound]
103 enumFromThen minBound (pred maxBound :: DocVersion) `shouldBe` [minBound, pred maxBound]
105 describe "Scan & Scroll API" $
106 it "returns documents using the scan&scroll API" $ withTestEnv $ do
111 (Just $ MatchAllQuery Nothing) Nothing)
113 regular_search <- searchTweet search
114 scan_search' <- scanSearch testIndex testMapping search :: BH IO [Hit Tweet]
115 let scan_search = map hitSource scan_search'
117 regular_search `shouldBe` Right exampleTweet -- Check that the size restrtiction is being honored
119 scan_search `shouldMatchList` [Just exampleTweet, Just otherTweet]
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list