{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}

-- | Shared payload types for the arbiter test suites.
module Arbiter.Test.Fixtures
  ( TestPayload (..)
  , WorkerTestPayload (..)
  ) where

import Arbiter.Core.Job.Kind (HasKind)
import Data.Aeson (FromJSON, ToJSON)
import Data.Text (Text)
import GHC.Generics (Generic)

-- | A payload for the core operation suites.
data TestPayload
  = TestMessage Text
  | TestCalculation Int Int
  deriving stock (TestPayload -> TestPayload -> Bool
(TestPayload -> TestPayload -> Bool)
-> (TestPayload -> TestPayload -> Bool) -> Eq TestPayload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TestPayload -> TestPayload -> Bool
== :: TestPayload -> TestPayload -> Bool
$c/= :: TestPayload -> TestPayload -> Bool
/= :: TestPayload -> TestPayload -> Bool
Eq, (forall x. TestPayload -> Rep TestPayload x)
-> (forall x. Rep TestPayload x -> TestPayload)
-> Generic TestPayload
forall x. Rep TestPayload x -> TestPayload
forall x. TestPayload -> Rep TestPayload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TestPayload -> Rep TestPayload x
from :: forall x. TestPayload -> Rep TestPayload x
$cto :: forall x. Rep TestPayload x -> TestPayload
to :: forall x. Rep TestPayload x -> TestPayload
Generic, Int -> TestPayload -> ShowS
[TestPayload] -> ShowS
TestPayload -> String
(Int -> TestPayload -> ShowS)
-> (TestPayload -> String)
-> ([TestPayload] -> ShowS)
-> Show TestPayload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TestPayload -> ShowS
showsPrec :: Int -> TestPayload -> ShowS
$cshow :: TestPayload -> String
show :: TestPayload -> String
$cshowList :: [TestPayload] -> ShowS
showList :: [TestPayload] -> ShowS
Show)
  deriving anyclass (Maybe TestPayload
Value -> Parser [TestPayload]
Value -> Parser TestPayload
(Value -> Parser TestPayload)
-> (Value -> Parser [TestPayload])
-> Maybe TestPayload
-> FromJSON TestPayload
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser TestPayload
parseJSON :: Value -> Parser TestPayload
$cparseJSONList :: Value -> Parser [TestPayload]
parseJSONList :: Value -> Parser [TestPayload]
$comittedField :: Maybe TestPayload
omittedField :: Maybe TestPayload
FromJSON, [TestPayload] -> Value
[TestPayload] -> Encoding
TestPayload -> Bool
TestPayload -> Value
TestPayload -> Encoding
(TestPayload -> Value)
-> (TestPayload -> Encoding)
-> ([TestPayload] -> Value)
-> ([TestPayload] -> Encoding)
-> (TestPayload -> Bool)
-> ToJSON TestPayload
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: TestPayload -> Value
toJSON :: TestPayload -> Value
$ctoEncoding :: TestPayload -> Encoding
toEncoding :: TestPayload -> Encoding
$ctoJSONList :: [TestPayload] -> Value
toJSONList :: [TestPayload] -> Value
$ctoEncodingList :: [TestPayload] -> Encoding
toEncodingList :: [TestPayload] -> Encoding
$comitField :: TestPayload -> Bool
omitField :: TestPayload -> Bool
ToJSON)

instance HasKind TestPayload

-- | A payload for the worker pool suites, with a failing and a slow variant.
data WorkerTestPayload
  = SimpleTask Text
  | FailingTask Int
  | SlowTask Int
  deriving stock (WorkerTestPayload -> WorkerTestPayload -> Bool
(WorkerTestPayload -> WorkerTestPayload -> Bool)
-> (WorkerTestPayload -> WorkerTestPayload -> Bool)
-> Eq WorkerTestPayload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WorkerTestPayload -> WorkerTestPayload -> Bool
== :: WorkerTestPayload -> WorkerTestPayload -> Bool
$c/= :: WorkerTestPayload -> WorkerTestPayload -> Bool
/= :: WorkerTestPayload -> WorkerTestPayload -> Bool
Eq, (forall x. WorkerTestPayload -> Rep WorkerTestPayload x)
-> (forall x. Rep WorkerTestPayload x -> WorkerTestPayload)
-> Generic WorkerTestPayload
forall x. Rep WorkerTestPayload x -> WorkerTestPayload
forall x. WorkerTestPayload -> Rep WorkerTestPayload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. WorkerTestPayload -> Rep WorkerTestPayload x
from :: forall x. WorkerTestPayload -> Rep WorkerTestPayload x
$cto :: forall x. Rep WorkerTestPayload x -> WorkerTestPayload
to :: forall x. Rep WorkerTestPayload x -> WorkerTestPayload
Generic, Int -> WorkerTestPayload -> ShowS
[WorkerTestPayload] -> ShowS
WorkerTestPayload -> String
(Int -> WorkerTestPayload -> ShowS)
-> (WorkerTestPayload -> String)
-> ([WorkerTestPayload] -> ShowS)
-> Show WorkerTestPayload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WorkerTestPayload -> ShowS
showsPrec :: Int -> WorkerTestPayload -> ShowS
$cshow :: WorkerTestPayload -> String
show :: WorkerTestPayload -> String
$cshowList :: [WorkerTestPayload] -> ShowS
showList :: [WorkerTestPayload] -> ShowS
Show)
  deriving anyclass (Maybe WorkerTestPayload
Value -> Parser [WorkerTestPayload]
Value -> Parser WorkerTestPayload
(Value -> Parser WorkerTestPayload)
-> (Value -> Parser [WorkerTestPayload])
-> Maybe WorkerTestPayload
-> FromJSON WorkerTestPayload
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser WorkerTestPayload
parseJSON :: Value -> Parser WorkerTestPayload
$cparseJSONList :: Value -> Parser [WorkerTestPayload]
parseJSONList :: Value -> Parser [WorkerTestPayload]
$comittedField :: Maybe WorkerTestPayload
omittedField :: Maybe WorkerTestPayload
FromJSON, [WorkerTestPayload] -> Value
[WorkerTestPayload] -> Encoding
WorkerTestPayload -> Bool
WorkerTestPayload -> Value
WorkerTestPayload -> Encoding
(WorkerTestPayload -> Value)
-> (WorkerTestPayload -> Encoding)
-> ([WorkerTestPayload] -> Value)
-> ([WorkerTestPayload] -> Encoding)
-> (WorkerTestPayload -> Bool)
-> ToJSON WorkerTestPayload
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: WorkerTestPayload -> Value
toJSON :: WorkerTestPayload -> Value
$ctoEncoding :: WorkerTestPayload -> Encoding
toEncoding :: WorkerTestPayload -> Encoding
$ctoJSONList :: [WorkerTestPayload] -> Value
toJSONList :: [WorkerTestPayload] -> Value
$ctoEncodingList :: [WorkerTestPayload] -> Encoding
toEncodingList :: [WorkerTestPayload] -> Encoding
$comitField :: WorkerTestPayload -> Bool
omitField :: WorkerTestPayload -> Bool
ToJSON)

instance HasKind WorkerTestPayload