question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testing Endpoints

See original GitHub issue

As asked on the Gitter channel, it would be nice to provide a meaning for testing Finch endpoints (routers).

The idea I’m suggesting relies on types we expose from endpoints (that’s a very good excuse to have them) and allows the users to treat endpoints as a regular functions so they could be easily tested.

Here is the example.

case class User(name: String)

val getUser: Endpoint[User] = get("users" / long) { id: Long =>
  User(id.toString)
}

// test
getUser.lift(100) shouldBe User("100")

The lift (or whatever) method lifts the endpoint to a function (A, B, ..., Z) => Out, where (A, B, ..., Z) are values extracted fromt the request by endpoint and Out is a returned value.

Not sure if it’s even possible, but I’d like to move Finch (make required chnages) towards the direction it will be possible.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:5
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
BenFradetcommented, Jul 18, 2016

Yup, I’ll start working on this.

0reactions
BenFradetcommented, Jul 19, 2016

fine with me

Read more comments on GitHub >

github_iconTop Results From Across the Web

A step-by-step intro to end-point testing
You can use Supertest to test endpoints. First, you need to install Supertest. ... Before you can test endpoints, you need to setup...
Read more >
What is API Testing? How to Test API Endpoints ...
API testing is a type of software testing that involves testing application programming interfaces (APIs) directly and as part of integration ...
Read more >
How to test API Endpoint?
Test API endpoints by making API requests directly from your browser. Check server status codes, response times, and sizes. Use ReqBin API ...
Read more >
You should Unit Test your API endpoints, it's easy!
An uncomplicated guide to unit test RESTful API endpoints in Go ... APIs in Go beyond Hello World” we'll look at an approach...
Read more >
Testing a REST API: Getting Started
If you design your endpoint so you make an API call for contacts first, then you have to make subsequent calls to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found