Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elgohr/stop-and-go
Testing helper for concurrency
https://github.com/elgohr/stop-and-go
concurrency go golang helper testing
Last synced: 7 days ago
JSON representation
Testing helper for concurrency
- Host: GitHub
- URL: https://github.com/elgohr/stop-and-go
- Owner: elgohr
- License: mit
- Created: 2020-11-06T09:04:58.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-15T16:48:55.000Z (6 months ago)
- Last Synced: 2024-10-10T18:46:47.819Z (24 days ago)
- Topics: concurrency, go, golang, helper, testing
- Language: Go
- Homepage:
- Size: 55.7 KB
- Stars: 10
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - stop-and-go - Testing helper for concurrency. (Testing / Testing Frameworks)
- awesome-go-extra - stop-and-go - 11-06T09:04:58Z|2022-06-29T16:23:11Z| (Testing / Testing Frameworks)
README
# stop-and-go
[![Actions Status](https://github.com/elgohr/stop-and-go/workflows/Test/badge.svg)](https://github.com/elgohr/stop-and-go/actions)
[![codecov](https://codecov.io/gh/elgohr/stop-and-go/branch/master/graph/badge.svg)](https://codecov.io/gh/elgohr/stop-and-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/elgohr/stop-and-go)](https://goreportcard.com/report/github.com/elgohr/stop-and-go)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/elgohr/stop-and-go)](https://pkg.go.dev/github.com/elgohr/stop-and-go)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)Testing helper for concurrency
## Install
```bash
go get -u github.com/elgohr/stop-and-go
```## Usage
```go
func TestExample(t *testing.T) {
w1 := wait.NewWaiter(time.Second)
w2 := wait.NewWaiter(time.Second)
w3 := wait.NewWaiter(time.Second)ts1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w2.Done()
}))
defer ts1.Close()go func() {
w3.Done()
}()go func() {
if _, err := http.Get(ts1.URL); err != nil {
t.Error(err)
}
w1.Done()
}()if err := wait.For(
constraint.NoOrder(w3),
constraint.Before(w1, w2),
); err != nil {
t.Error(err)
}
}
```