@@ -14,6 +14,7 @@ import Data.Aeson.Types (parseEither)
1414import Data.DeriveTH
1515import qualified Data.HashMap.Strict as HM
1616import Data.List (nub)
17+import qualified Data.List as L
1718import Data.List.NonEmpty (NonEmpty (..))
1819import qualified Data.List.NonEmpty as NE
1920import qualified Data.Map.Strict as M
@@ -981,6 +982,24 @@ main = hspec $ do
981982 liftIO $
982983 scan_search `shouldMatchList` [Just exampleTweet, Just otherTweet]
983984
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
990+
991+ withTestEnv $ do
992+ resetIndex
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
998+ case aliases of
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
1002+
9841003 describe "JSON instances" $ do
9851004 propJSON (Proxy :: Proxy Version)
9861005 propJSON (Proxy :: Proxy IndexName)