Skip to content

Conversation

@PedroEdiaz
Copy link

This commit allow for serverless testing, this is a code snippet on how to use it:

import "core:testing"
import http "."

@(test)
test_handler :: proc(t: ^testing.T) {
	http.td.state=.Testing

	req : http.Request
	res : http.Response

	handler(&req, &res)

	testing.expect( t, res.status==.OK )
}

The testing report leaks but I'm not sure if those are from this pull request

        +++ leak       448B @ 0x7FA2B31210C0 [headers.odin:37:headers_set_unsafe()]
        +++ leak       113B @ 0x7FA2B3121288 [response.odin:227:_response_write_heading()]

An example of how to test a handler with this commit:

```
import "core:testing"
import http "."

@(test)
test_handler :: proc(t: ^testing.T) {
	http.td.state=.Testing

	req : http.Request
	res : http.Response

	handler(&req, &res)

	testing.expect( t, res.status==.OK )
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant