Skip to content

Commit

Permalink
Issue #26: share common parts between test vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Dimjašević committed Nov 21, 2019
1 parent cd3f0d3 commit 897200b
Showing 1 changed file with 20 additions and 46 deletions.
66 changes: 20 additions & 46 deletions test/Fencer/Rules/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,27 @@ test_rulesYAMLSeparator =
-- Sample definitions
----------------------------------------------------------------------------

descriptor1 :: DescriptorDefinition
descriptor1 = DescriptorDefinition
{ descriptorDefinitionKey = RuleKey "some key"
, descriptorDefinitionValue = Just $ RuleValue "some value"
, descriptorDefinitionRateLimit = Nothing
, descriptorDefinitionDescriptors = Nothing
}

descriptor2 :: DescriptorDefinition
descriptor2 = DescriptorDefinition
{ descriptorDefinitionKey = RuleKey "some key 2"
, descriptorDefinitionValue = Nothing
, descriptorDefinitionRateLimit = Nothing
, descriptorDefinitionDescriptors = Nothing
}

domain1 :: DomainDefinition
domain1 = DomainDefinition
{ domainDefinitionId = DomainId "domain1"
, domainDefinitionDescriptors = [descriptor1]
}
where
descriptor1 :: DescriptorDefinition
descriptor1 = DescriptorDefinition
{ descriptorDefinitionKey = RuleKey "some key"
, descriptorDefinitionValue = Just $ RuleValue "some value"
, descriptorDefinitionRateLimit = Nothing
, descriptorDefinitionDescriptors = Nothing
}

domain1Text :: Text
domain1Text = [text|
Expand All @@ -227,14 +235,6 @@ domain2 = DomainDefinition
{ domainDefinitionId = DomainId "domain2"
, domainDefinitionDescriptors = [descriptor2]
}
where
descriptor2 :: DescriptorDefinition
descriptor2 = DescriptorDefinition
{ descriptorDefinitionKey = RuleKey "some key 2"
, descriptorDefinitionValue = Nothing
, descriptorDefinitionRateLimit = Nothing
, descriptorDefinitionDescriptors = Nothing
}

domain2Text :: Text
domain2Text = [text|
Expand Down Expand Up @@ -271,39 +271,13 @@ separatorDomainText = [text|
---
domain: another
descriptors:
- key: key2
rate_limit:
unit: minute
requests_per_unit: 20
- key: key3
rate_limit:
unit: hour
requests_per_unit: 10
- key: some key
value: some value
- key: some key 2
|]

separatorDomain :: DomainDefinition
separatorDomain = DomainDefinition
{ domainDefinitionId = DomainId "another"
, domainDefinitionDescriptors = [desc1, desc2]
, domainDefinitionDescriptors = [descriptor1, descriptor2]
}
where
desc1 :: DescriptorDefinition
desc1 = DescriptorDefinition
{ descriptorDefinitionKey = RuleKey "key2"
, descriptorDefinitionValue = Nothing
, descriptorDefinitionRateLimit = Just $ RateLimit
{ rateLimitUnit = Minute
, rateLimitRequestsPerUnit = 20
}
, descriptorDefinitionDescriptors = Nothing
}
desc2 :: DescriptorDefinition
desc2 = DescriptorDefinition
{ descriptorDefinitionKey = RuleKey "key3"
, descriptorDefinitionValue = Nothing
, descriptorDefinitionRateLimit = Just $ RateLimit
{ rateLimitUnit = Hour
, rateLimitRequestsPerUnit = 10
}
, descriptorDefinitionDescriptors = Nothing
}

0 comments on commit 897200b

Please sign in to comment.