Skip to content

Commit

Permalink
Merge pull request #130 from hmrc/BDOG-1393
Browse files Browse the repository at this point in the history
BDOG-1393: Update README, to mention testing more
  • Loading branch information
cjwebb authored May 20, 2021
2 parents e97ae17 + 88e40d2 commit 8444bc2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ target
.metals/
.vscode/
metals.sbt
.bsp/

nohup.out
rebel.xml
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ http-verbs is a Scala library providing an interface to make asynchronous HTTP c

It encapsulates some common concerns for calling other HTTP services on the HMRC Tax Platform, including:

* Logging
* Header Carrier
* Http Transport
* Core Http function interfaces
* executing hooks
* mapping errors
* Auditing
* Logging
* Propagation of common headers
* Response handling, converting failure status codes into a consistent set of exceptions - allows failures to be automatically propagated to the caller
* Executing hooks, for example Auditing
* Request & Response de-serializations
* Response handling, converting failure status codes into a consistent set of exceptions - allows failures to be automatically propagated to the caller

## Migration

Expand Down Expand Up @@ -98,7 +94,7 @@ For all other headers, provide them to the VERB function:
client.GET(url = url"https://internalhost/api", headers = Seq("AdditionHeader" -> "AdditionalValue"))(hc)
```

## Test Helpers
## Testing

The ResponseMatchers class provides some useful logic for testing http-related code.

Expand All @@ -108,6 +104,10 @@ In your SBT build add the following in your test dependencies:
libraryDependencies += "uk.gov.hmrc" %% "http-verbs-test-play-xx" % "x.x.x" % Test
```

We also recommend that Wiremock is used for testing http-verbs code, with extensive assertions on the URL, Headers, and Body fields for both requests and responses. This will test most things, doesn't involve "mocking what you don't own", and ensures that changes to this library will be caught.

The only notable exception to this advice is when testing code that will interact with external-hosts. In your tests, you should set the host to `127.0.0.1` or similar, as `localhost` will get identified as an internal-host. The behaviour of propagating the headers differs based on this.


## License ##

Expand Down

0 comments on commit 8444bc2

Please sign in to comment.