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 Data.Aeson as Aeson
22import qualified Test.Aggregation as Aggregation
23import qualified Test.BulkAPI as Bulk
24import qualified Test.Documents as Documents
25import qualified Test.Highlights as Highlights
26import qualified Test.Indices as Indices
27import qualified Test.JSON as JSON
28import qualified Test.Query as Query
29import qualified Test.Script as Script
30import qualified Test.Snapshots as Snapshots
31import qualified Test.Sorting as Sorting
32import qualified Test.SourceFiltering as SourceFiltering
33import qualified Test.Suggest as Suggest
34import qualified Test.Templates as Templates
52 describe "error parsing" $ do
53 it "can parse EsErrors for < 2.0" $ when' (atmost es16) $ withTestEnv $ do
54 res <- getDocument (IndexName "bogus") (MappingName "also_bogus") (DocId "bogus_as_well")
55 let errorResp = eitherDecode (responseBody res)
56 liftIO (errorResp `shouldBe` Right (EsError 404 "IndexMissingException[[bogus] missing]"))
58 it "can parse EsErrors for >= 2.0" $ when' (atleast es20) $ withTestEnv $ do
59 res <- getDocument (IndexName "bogus") (MappingName "also_bogus") (DocId "bogus_as_well")
60 let errorResp = eitherDecode (responseBody res)
61 liftIO (errorResp `shouldBe` Right (EsError 404 "no such index"))
63 describe "Monoid (SearchHits a)" $
64 prop "abides the monoid laws" $ eq $
65 prop_Monoid (T :: T (SearchHits ()))
67 describe "mkDocVersion" $
68 prop "can never construct an out of range docVersion" $ \i ->
69 let res = mkDocVersion i
71 Nothing -> property True
72 Just dv -> (dv >= minBound) .&&.
74 docVersionNumber dv === i
76 describe "getNodesInfo" $
77 it "fetches the responding node when LocalNode is used" $ withTestEnv $ do
78 res <- getNodesInfo LocalNode
80 -- This is really just a smoke test for response
81 -- parsing. Node info is so variable, there's not much I can
83 Right NodesInfo {..} -> length nodesInfo `shouldBe` 1
84 Left e -> expectationFailure ("Expected NodesInfo but got " <> show e)
86 describe "getNodesStats" $
87 it "fetches the responding node when LocalNode is used" $ withTestEnv $ do
88 res <- getNodesStats LocalNode
90 -- This is really just a smoke test for response
91 -- parsing. Node stats is so variable, there's not much I can
93 Right NodesStats {..} -> length nodesStats `shouldBe` 1
94 Left e -> expectationFailure ("Expected NodesStats but got " <> show e)
96 describe "Enum DocVersion" $
97 it "follows the laws of Enum, Bounded" $ do
98 evaluate (succ maxBound :: DocVersion) `shouldThrow` anyErrorCall
99 evaluate (pred minBound :: DocVersion) `shouldThrow` anyErrorCall
100 evaluate (toEnum 0 :: DocVersion) `shouldThrow` anyErrorCall
101 evaluate (toEnum 9200000000000000001 :: DocVersion) `shouldThrow` anyErrorCall
102 enumFrom (pred maxBound :: DocVersion) `shouldBe` [pred maxBound, maxBound]
103 enumFrom (pred maxBound :: DocVersion) `shouldBe` [pred maxBound, maxBound]
104 enumFromThen minBound (pred maxBound :: DocVersion) `shouldBe` [minBound, pred maxBound]
106 describe "Scan & Scroll API" $
107 it "returns documents using the scan&scroll API" $ withTestEnv $ do
112 (Just $ MatchAllQuery Nothing) Nothing)
114 regular_search <- searchTweet search
115 scan_search' <- scanSearch testIndex testMapping search :: BH IO [Hit Tweet]
116 let scan_search = map hitSource scan_search'
118 regular_search `shouldBe` Right exampleTweet -- Check that the size restrtiction is being honored
120 scan_search `shouldMatchList` [Just exampleTweet, Just otherTweet]
122 describe "Search After API" $
123 it "returns document for search after query" $ withTestEnv $ do
127 sortSpec = DefaultSortSpec $ mkSort (FieldName "user") Ascending
128 searchAfterKey = [Aeson.toJSON ("bitemyapp" :: String)]
129 search = Search Nothing
130 Nothing (Just [sortSpec]) Nothing Nothing
131 False (From 0) (Size 10) SearchTypeQueryThenFetch (Just searchAfterKey)
132 Nothing Nothing Nothing Nothing
133 result <- searchTweets search
134 let myTweet = grabFirst result
136 myTweet `shouldBe` Right 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