From 8acd447803c37694cc4608565a6d7444ce491b9e Mon Sep 17 00:00:00 2001 From: Daniel Chambers Date: Mon, 27 Mar 2023 13:21:17 +1100 Subject: [PATCH] Fix non-determinism in expected ordering in agent test suite test PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8493 GitOrigin-RevId: 210b6beb991d806e9a3e4cc901ee922ede0e3c84 --- .../test/Test/Specs/MutationSpec/DeleteSpec.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server/lib/dc-api/test/Test/Specs/MutationSpec/DeleteSpec.hs b/server/lib/dc-api/test/Test/Specs/MutationSpec/DeleteSpec.hs index b270f645928..4b241274871 100644 --- a/server/lib/dc-api/test/Test/Specs/MutationSpec/DeleteSpec.hs +++ b/server/lib/dc-api/test/Test/Specs/MutationSpec/DeleteSpec.hs @@ -6,7 +6,9 @@ import Data.Aeson qualified as J import Data.Foldable (for_) import Data.Functor ((<&>)) import Data.HashMap.Strict (HashMap) +import Data.List (sortOn) import Data.List.NonEmpty (NonEmpty (..)) +import Data.List.NonEmpty qualified as NonEmpty import Data.Maybe (fromMaybe, maybeToList) import Hasura.Backends.DataConnector.API import Test.AgentAPI (mutationGuarded, queryGuarded) @@ -224,6 +226,14 @@ spec TestData {..} edgeCasesTestData Capabilities {..} = describe "Delete Mutati [ ("PlaylistId", _tdColumnField _tdPlaylistTracksTableName "PlaylistId"), ("TrackId", _tdColumnField _tdPlaylistTracksTableName "TrackId") ] + & qOrderBy + ?~ OrderBy + mempty + ( NonEmpty.fromList + [ _tdOrderByColumn [] "PlaylistId" Ascending, + _tdOrderByColumn [] "TrackId" Ascending + ] + ) ) ) ) @@ -245,7 +255,10 @@ spec TestData {..} edgeCasesTestData Capabilities {..} = describe "Delete Mutati let joinInPlaylistTracks (track :: HashMap FieldName FieldValue) = let trackId = track ^? Data.field "TrackId" . Data._ColumnFieldNumber - playlistTracks = _tdPlaylistTracksRows & filter (\playlistTrack -> playlistTrack ^? Data.field "TrackId" . Data._ColumnFieldNumber == trackId) + playlistTracks = + _tdPlaylistTracksRows + & filter (\playlistTrack -> playlistTrack ^? Data.field "TrackId" . Data._ColumnFieldNumber == trackId) + & sortOn (\playlistTrack -> (playlistTrack ^? Data.field "PlaylistId", playlistTrack ^? Data.field "TrackId")) in Data.insertField "PlaylistTracks" (Data.mkSubqueryRowsFieldValue playlistTracks) track let joinInTrack (invoiceLine :: HashMap FieldName FieldValue) =