prop_queryJob_Unknown :: Property
prop_queryJob_Unknown =
  forAll (listOf (arbitrary::Gen (Positive Integer))) $ \ids ->
  forAll (arbitrary `suchThat` (`notElem` Map.keys Job.fieldsMap))
    $ \field -> monadicIO $ do
  let qtype = ItemTypeLuxi QRJob
      flt = makeSimpleFilter (nameField qtype) $
            map (\(Positive i) -> Right i) ids
  QueryResult fdefs fdata <-
    run (query undefined False (Query qtype [field] flt)) >>= resultProp
  QueryFieldsResult fdefs' <-
    resultProp $ queryFields (QueryFields qtype [field])
  _ <- stop $ conjoin
         [ counterexample ("Got known fields via query (" ++ show fdefs ++ ")")
           (not $ hasUnknownFields fdefs)
         , counterexample ("Got /= ResultUnknown result status via query (" ++
                           show fdata ++ ")")
           (all (all ((== RSUnknown) . rentryStatus)) fdata)
         , counterexample ("Got a Just in a result value (" ++
                           show fdata ++ ")")
           (all (all (isNothing . rentryValue)) fdata)
         , counterexample ("Got known fields via query fields (" ++ show fdefs'
                           ++ ")") (not $ hasUnknownFields fdefs')
         ]
  return ()

-- ** Misc other tests

-- | Tests that requested names checking behaves as expected.
prop_queryJob_Unknown :: Property
prop_queryJob_Unknown =
  forAll (listOf (arbitrary::Gen (Positive Integer))) $ \ids ->
  forAll (arbitrary `suchThat` (`notElem` Map.keys Job.fieldsMap))
    $ \field -> monadicIO $ do
  let qtype = ItemTypeLuxi QRJob
      flt = makeSimpleFilter (nameField qtype) $
            map (\(Positive i) -> Right i) ids
  QueryResult fdefs fdata <-
    run (query undefined False (Query qtype [field] flt)) >>= resultProp
  QueryFieldsResult fdefs' <-
    resultProp $ queryFields (QueryFields qtype [field])
  _ <- stop $ conjoin
         [ counterexample ("Got known fields via query (" ++ show fdefs ++ ")")
           (not $ hasUnknownFields fdefs)
         , counterexample ("Got /= ResultUnknown result status via query (" ++
                           show fdata ++ ")")
           (all (all ((== RSUnknown) . rentryStatus)) fdata)
         , counterexample ("Got a Just in a result value (" ++
                           show fdata ++ ")")
           (all (all (isNothing . rentryValue)) fdata)
         , counterexample ("Got known fields via query fields (" ++ show fdefs'
                           ++ ")") (not $ hasUnknownFields fdefs')
         ]
  return ()

-- ** Misc other tests

-- | Tests that requested names checking behaves as expected.
prop_queryJob_Unknown =
  forAll (listOf (arbitrary::Gen (Positive Integer))) $ \ids ->
  forAll (arbitrary `suchThat` (`notElem` Map.keys Job.fieldsMap))
    $ \field -> monadicIO $ do
  let qtype = ItemTypeLuxi QRJob
      flt = makeSimpleFilter (nameField qtype) $
            map (\(Positive i) -> Right i) ids
  QueryResult fdefs fdata <-
    run (query undefined False (Query qtype [field] flt)) >>= resultProp
  QueryFieldsResult fdefs' <-
    resultProp $ queryFields (QueryFields qtype [field])
  _ <- stop $ conjoin
         [ counterexample ("Got known fields via query (" ++ show fdefs ++ ")")
           (not $ hasUnknownFields fdefs)
         , counterexample ("Got /= ResultUnknown result status via query (" ++
                           show fdata ++ ")")
           (all (all ((== RSUnknown) . rentryStatus)) fdata)
         , counterexample ("Got a Just in a result value (" ++
                           show fdata ++ ")")
           (all (all (isNothing . rentryValue)) fdata)
         , counterexample ("Got known fields via query fields (" ++ show fdefs'
                           ++ ")") (not $ hasUnknownFields fdefs')
         ]
  return ()

-- ** Misc other tests

-- | Tests that requested names checking behaves as expected.