Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suzuki-shunsuke/flute
Golang HTTP client testing framework
https://github.com/suzuki-shunsuke/flute
golang library mock oss testing
Last synced: about 1 month ago
JSON representation
Golang HTTP client testing framework
- Host: GitHub
- URL: https://github.com/suzuki-shunsuke/flute
- Owner: suzuki-shunsuke
- License: mit
- Created: 2019-07-06T04:32:03.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-28T03:56:47.000Z (about 2 months ago)
- Last Synced: 2024-10-28T04:35:57.738Z (about 2 months ago)
- Topics: golang, library, mock, oss, testing
- Language: Go
- Homepage: https://pkg.go.dev/github.com/suzuki-shunsuke/flute/flute
- Size: 271 KB
- Stars: 19
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-go - flute - HTTP client testing framework. (Testing / Testing Frameworks)
- zero-alloc-awesome-go - flute - HTTP client testing framework. (Testing / HTTP Clients)
- awesome-go-extra - flute - 07-06T04:32:03Z|2022-06-23T20:33:27Z| (Testing / Testing Frameworks)
README
# flute
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)
[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://pkg.go.dev/github.com/suzuki-shunsuke/flute/flute)
[![Go Report Card](https://goreportcard.com/badge/github.com/suzuki-shunsuke/flute)](https://goreportcard.com/report/github.com/suzuki-shunsuke/flute)
[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/suzuki-shunsuke/flute/main/LICENSE)Golang HTTP client testing framework
## Presentation
https://speakerdeck.com/szksh/flute-golang-http-client-testing-framework
## Overview
`flute` is the Golang HTTP client testing framework.
The goal is* Test request parameters such as the request path, headers and body
* Mock the HTTP server`flute.Transport` implements [http.RoundTripper](https://golang.org/pkg/net/http/#RoundTripper).
`flute` uses [testify](https://github.com/stretchr/testify)'s assert internally.
You can test the http request parameters with assert.For example, the following test failure message means the request header is unexpected value.
```console
=== RUN TestClient_CreateUser
--- FAIL: TestClient_CreateUser (0.00s)
tester.go:168:
Error Trace: tester.go:168
tester.go:32
transport.go:25
client.go:250
client.go:174
client.go:641
client.go:509
create_user.go:45
create_user_test.go:56
Error: Not equal:
expected: []string{"token XXXXX"}
actual : []string{"token "}Diff:
--- Expected
+++ Actual
@@ -1,3 +1,3 @@
([]string) (len=1) {
- (string) (len=11) "token XXXXX"
+ (string) (len=6) "token "
}
Test: TestClient_CreateUser
Messages: the request header "Authorization" should match
service: http://example.com
request name: create a user
```Please see [the example](https://github.com/suzuki-shunsuke/flute/blob/v0.6.0/examples/create_user_test.go#L21-L48).
## Example
Please see [examples](examples).
## License
[MIT](LICENSE)