Skip to content

Commit

Permalink
Support key with leading underscore (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviaviavi committed Oct 21, 2019
1 parent e672047 commit 9f08b25
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
4 changes: 3 additions & 1 deletion README.md
@@ -1,6 +1,8 @@
# curl-runnings

[![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)
[![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)
[![Scarf](https://scarf.sh/package/badge/curl-runnings)](https://scarf.sh/package/avi/curl-runnings)

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

Expand Down
6 changes: 3 additions & 3 deletions curl-runnings.cabal
@@ -1,13 +1,13 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.31.1.
-- This file has been generated from package.yaml by hpack version 0.31.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: b7f43a448b7bffd8bc3340f6483fb99f6391934bc869150ced8021708ca83864
-- hash: c5eff7acb49843acbacdcf64e3e57fd05242eee41e466f2468cc9bf696b5f666

name: curl-runnings
version: 0.11.0
version: 0.11.1
synopsis: A framework for declaratively writing curl based API tests
description: Please see the README on Github at <https://github.com/aviaviavi/curl-runnings#readme>
category: Testing
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
@@ -1,5 +1,5 @@
name: curl-runnings
version: 0.11.0
version: 0.11.1
github: aviaviavi/curl-runnings
license: MIT
author: Avi Press
Expand Down
6 changes: 3 additions & 3 deletions src/Testing/CurlRunnings/Internal/Parser.hs
@@ -1,4 +1,4 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}

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

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

jsonIndexParser :: Parser Query
jsonIndexParser =
Expand Down
1 change: 1 addition & 0 deletions test/Spec.hs
Expand Up @@ -27,6 +27,7 @@ main = hspec $
parseQuery "just some text" `shouldSatisfy` isRight
parseQuery "$<RESPONSES[0].key.key>" `shouldSatisfy` isRight
parseQuery "$<RESPONSES[0].key.key[0].key_with_underscores>" `shouldSatisfy` isRight
parseQuery "$<RESPONSES[0].key.key[0]._key_starts_with_underscores>" `shouldSatisfy` isRight
parseQuery "$<RESPONSES[100].key.key[0].key_with_underscores>" `shouldSatisfy` isRight
parseQuery "some text before $<RESPONSES[100].key.key[0].key_with_underscores> and after" `shouldSatisfy` isRight
parseQuery "some $<RESPONSES[100]> querires $<RESPONSES[100]>" `shouldSatisfy` isRight
Expand Down

0 comments on commit 9f08b25

Please sign in to comment.