diff --git a/test.sh b/test.sh index 1125cf325..16840a25e 100755 --- a/test.sh +++ b/test.sh @@ -11,4 +11,4 @@ if [[ -d .stack-work-test ]]; then trap move-back EXIT fi -exec -- stack build --test --coverage --fast --flag uniworx:dev --flag uniworx:library-only ${@} +stack build --test --coverage --fast --flag uniworx:dev --flag uniworx:library-only ${@} diff --git a/test/Model/TypesSpec.hs b/test/Model/TypesSpec.hs index 4c74f0720..33a438411 100644 --- a/test/Model/TypesSpec.hs +++ b/test/Model/TypesSpec.hs @@ -8,7 +8,6 @@ import Settings import Control.Lens (review, preview) import Data.Aeson (Value) import qualified Data.Aeson as Aeson -import Data.Word (Word16) import MailSpec () @@ -24,6 +23,8 @@ import qualified Data.Set as Set import Time.Types (WeekDay(..)) +import qualified Net.IP as IP + instance (Arbitrary a, MonoFoldable a) => Arbitrary (NonNull a) where arbitrary = arbitrary `suchThatMap` fromNullable @@ -185,20 +186,12 @@ instance Arbitrary LecturerType where arbitrary = genericArbitrary shrink = genericShrink -instance Arbitrary StdMethod where - arbitrary = genericArbitrary - shrink = genericShrink +instance Arbitrary IP where + arbitrary = oneof + [ IP.ipv4 <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary + , IP.ipv6 <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary + ] -instance Arbitrary SockAddr where - arbitrary = genericArbitrary - shrink = genericShrink - -instance Arbitrary PortNumber where - arbitrary = (fromIntegral :: Word16 -> PortNumber) <$> arbitrary - -instance Arbitrary RequestInfo where - arbitrary = genericArbitrary - shrink = genericShrink instance {-# OVERLAPPABLE #-} ToBackendKey SqlBackend record => Arbitrary (Key record) where arbitrary = toSqlKey <$> arbitrary shrink = map toSqlKey . shrink . fromSqlKey @@ -284,14 +277,8 @@ spec = do [ eqLaws, ordLaws, showReadLaws, jsonLaws, persistFieldLaws ] lawsCheckHspec (Proxy @LecturerType) [ eqLaws, ordLaws, showReadLaws, boundedEnumLaws, finiteLaws, jsonLaws, pathPieceLaws, persistFieldLaws ] - lawsCheckHspec (Proxy @StdMethod) + lawsCheckHspec (Proxy @IP) [ eqLaws, ordLaws, showReadLaws, jsonLaws ] - lawsCheckHspec (Proxy @SockAddr) - [ eqLaws, ordLaws, jsonLaws ] - lawsCheckHspec (Proxy @PortNumber) - [ eqLaws, ordLaws, showReadLaws, jsonLaws ] - lawsCheckHspec (Proxy @RequestInfo) - [ eqLaws, ordLaws, jsonLaws, persistFieldLaws ] describe "TermIdentifier" $ do it "has compatible encoding/decoding to/from Text" . property $ diff --git a/test/TestImport.hs b/test/TestImport.hs index 4fb09576b..9164c3144 100644 --- a/test/TestImport.hs +++ b/test/TestImport.hs @@ -36,6 +36,8 @@ import Numeric.Natural as X import Control.Lens as X hiding ((<.), elements) +import Net.IP as X (IP) + import Database (truncateDb) import Database as X (fillDb)