@@ -14,6 +14,7 @@ import Data.Aeson.Types (parseEither)
14import Data.DeriveTH
14import Data.DeriveTH
15import qualified Data.HashMap.Strict as HM
15import qualified Data.HashMap.Strict as HM
16import Data.List (nub)
16import Data.List (nub)
17+import qualified Data.List as L
17import Data.List.NonEmpty (NonEmpty (..))
18import Data.List.NonEmpty (NonEmpty (..))
18import qualified Data.List.NonEmpty as NE
19import qualified Data.List.NonEmpty as NE
19import qualified Data.Map.Strict as M
20import qualified Data.Map.Strict as M
@@ -981,6 +982,24 @@ main = hspec $ do
982 scan_search `shouldMatchList` [Just exampleTweet, Just otherTweet]
983 scan_search `shouldMatchList` [Just exampleTweet, Just otherTweet]
985+ describe "index aliases" $ do
986+ it "handles the simple case of aliasing an existing index" $ do
987+ let alias = IndexAlias (testIndex) (IndexAliasName (IndexName "bloodhound-tests-twitter-1-alias"))
988+ let create = IndexAliasCreate Nothing Nothing
989+ let action = AddAlias alias create
993+ resp <- updateIndexAliases (action :| [])
994+ liftIO $ NHTS.statusCode (responseStatus resp) `shouldBe` 200
995+ let cleanup = withTestEnv (updateIndexAliases (RemoveAlias alias :| []))
996+ (do aliases <- withTestEnv getIndexAliases
997+ let expected = IndexAliasSummary alias create
999+ Right (IndexAliasesSummary summs) ->
1000+ L.find ((== alias) . indexAliasSummaryAlias) summs `shouldBe` Just expected
1001+ Left e -> expectationFailure ("Expected an IndexAliasesSummary but got " <> show e)) `finally` cleanup
984 describe "JSON instances" $ do
1003 describe "JSON instances" $ do
985 propJSON (Proxy :: Proxy Version)
1004 propJSON (Proxy :: Proxy Version)
986 propJSON (Proxy :: Proxy IndexName)
1005 propJSON (Proxy :: Proxy IndexName)