Skip to content

Commit 9f08b25

Browse files
authored
Support key with leading underscore (#43)
1 parent e672047 commit 9f08b25

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# curl-runnings
22

3-
[![Build Status](https://travis-ci.org/aviaviavi/curl-runnings.svg?branch=master)](https://travis-ci.org/aviaviavi/curl-runnings) [![Hackage](https://img.shields.io/hackage/v/curl-runnings.svg)](https://hackage.haskell.org/package/curl-runnings)
3+
[![Build Status](https://travis-ci.org/aviaviavi/curl-runnings.svg?branch=master)](https://travis-ci.org/aviaviavi/curl-runnings)
4+
[![Hackage](https://img.shields.io/hackage/v/curl-runnings.svg)](https://hackage.haskell.org/package/curl-runnings)
5+
[![Scarf](https://scarf.sh/package/badge/curl-runnings)](https://scarf.sh/package/avi/curl-runnings)
46

57
_Feel the rhythm! Feel the rhyme! Get on up, it's testing time! curl-runnings!_
68

curl-runnings.cabal

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.31.1.
3+
-- This file has been generated from package.yaml by hpack version 0.31.2.
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: b7f43a448b7bffd8bc3340f6483fb99f6391934bc869150ced8021708ca83864
7+
-- hash: c5eff7acb49843acbacdcf64e3e57fd05242eee41e466f2468cc9bf696b5f666
88

99
name: curl-runnings
10-
version: 0.11.0
10+
version: 0.11.1
1111
synopsis: A framework for declaratively writing curl based API tests
1212
description: Please see the README on Github at <https://github.com/aviaviavi/curl-runnings#readme>
1313
category: Testing

package.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: curl-runnings
2-
version: 0.11.0
2+
version: 0.11.1
33
github: aviaviavi/curl-runnings
44
license: MIT
55
author: Avi Press

src/Testing/CurlRunnings/Internal/Parser.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE OverloadedStrings #-}
1+
{-# LANGUAGE OverloadedStrings #-}
22

33
-- | Internal module for parsing string based directives inside of curl runnings
44
-- suites. Use this module at your own risk, it may change. Currently, string
@@ -48,7 +48,7 @@ parseQuery q =
4848
let trimmed = T.strip q
4949
in case Text.Megaparsec.parse parseFullTextWithQuery "" trimmed of
5050
Right a -> Right a >>= validateQuery
51-
Left a -> Left $ QueryParseError (T.pack $ errorBundlePretty a) q
51+
Left a -> Left $ QueryParseError (T.pack $ errorBundlePretty a) q
5252

5353
-- | Once we have parsed a query successfully, ensure that it is a legal query
5454
validateQuery :: [InterpolatedQuery] -> Either QueryError [InterpolatedQuery]
@@ -121,7 +121,7 @@ keyIndexParser = do
121121
notFollowedBy endingChars
122122
(lexeme . try) ((KeyIndex . T.pack) <$> p)
123123
where
124-
p = (:) <$> letterChar <*> many (noneOf ['.', '[', ']', '<', '>', ' ', '{', '}'])
124+
p = (:) <$> (letterChar <|> (char '_')) <*> many (noneOf ['.', '[', ']', '<', '>', ' ', '{', '}'])
125125

126126
jsonIndexParser :: Parser Query
127127
jsonIndexParser =

test/Spec.hs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ main = hspec $
2727
parseQuery "just some text" `shouldSatisfy` isRight
2828
parseQuery "$<RESPONSES[0].key.key>" `shouldSatisfy` isRight
2929
parseQuery "$<RESPONSES[0].key.key[0].key_with_underscores>" `shouldSatisfy` isRight
30+
parseQuery "$<RESPONSES[0].key.key[0]._key_starts_with_underscores>" `shouldSatisfy` isRight
3031
parseQuery "$<RESPONSES[100].key.key[0].key_with_underscores>" `shouldSatisfy` isRight
3132
parseQuery "some text before $<RESPONSES[100].key.key[0].key_with_underscores> and after" `shouldSatisfy` isRight
3233
parseQuery "some $<RESPONSES[100]> querires $<RESPONSES[100]>" `shouldSatisfy` isRight

0 commit comments

Comments
 (0)