https://github.com/achiku/hseq
Generate hash + sequence for tests
https://github.com/achiku/hseq
golang testing
Last synced: about 1 year ago
JSON representation
Generate hash + sequence for tests
- Host: GitHub
- URL: https://github.com/achiku/hseq
- Owner: achiku
- License: mit
- Created: 2017-02-18T10:16:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-04-03T06:03:31.000Z (over 2 years ago)
- Last Synced: 2025-02-14T16:39:54.156Z (over 1 year ago)
- Topics: golang, testing
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hseq
[](https://travis-ci.org/achiku/hseq)
[](https://raw.githubusercontent.com/achiku/hseq/master/LICENSE)
[](https://goreportcard.com/report/github.com/achiku/hseq)
Simply generating sequence values for tests
## Why created
In tests, it is very helpful to have unique sequence values for a name, especially when it interact with RDBMS primary key or unique constraints. This library makes it easier to set up unique sequence values in Go tests.
## Installation
```
go get -u github.com/achiku/hseq
```
## How to use
```go
package main
import (
"log"
"github.com/achiku/hseq"
)
type st struct {
ID int64
UniqueNumber int
UniqueName string
}
func main() {
st1 := st{
ID: hseq.Get("st.id").Int64(),
UniqueNumber: hseq.Get("st.unique_number").Int(),
UniqueName: hseq.Get("st.unique_name").String(),
}
st2 := st{
ID: hseq.Get("st.id").Int64(),
UniqueNumber: hseq.Get("st.unique_number").Int(),
UniqueName: hseq.Get("st.unique_name").String(),
}
log.Printf("%+v", st1)
log.Printf("%+v", st2)
}
```