Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qawatake/faketest
Fakes should be random.
https://github.com/qawatake/faketest
go golang testing
Last synced: 7 days ago
JSON representation
Fakes should be random.
- Host: GitHub
- URL: https://github.com/qawatake/faketest
- Owner: qawatake
- License: mit
- Created: 2024-07-29T12:26:53.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-29T13:52:14.000Z (5 months ago)
- Last Synced: 2024-10-29T12:56:49.416Z (about 2 months ago)
- Topics: go, golang, testing
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# faketest
[![Go Reference](https://pkg.go.dev/badge/github.com/qawatake/faketest.svg)](https://pkg.go.dev/github.com/qawatake/faketest)
[![test](https://github.com/qawatake/faketest/actions/workflows/test.yaml/badge.svg)](https://github.com/qawatake/faketest/actions/workflows/test.yaml)
[![codecov](https://codecov.io/gh/qawatake/faketest/graph/badge.svg)](https://codecov.io/gh/qawatake/faketest)Fakes should be random.
```go
func TestGood(t *testing.T) {
t.Parallel()
faketest.AssertEachFieldIsRandom(t, Good) // OK
}func TestBad(t *testing.T) {
t.Parallel()
faketest.AssertEachFieldIsRandom(t, Bad) // "Book.Name is not random"
}type Book struct {
ID int64
Name string
}func Good() *Book {
return &Book{
ID: rand.Int64(),
Name: []string{"Macbeth", "Hamlet", "Othello"}[rand.IntN(3)],
}
}func Bad() *Book {
return &Book{
ID: rand.Int64(),
Name: "Fixed",
}
}
```