https://github.com/potatogopher/marigold
https://github.com/potatogopher/marigold
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/potatogopher/marigold
- Owner: potatogopher
- Created: 2016-05-22T14:01:15.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-23T12:51:06.000Z (about 10 years ago)
- Last Synced: 2025-06-04T10:19:06.890Z (about 1 year ago)
- Language: Ruby
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Marigold
[](https://badge.fury.io/rb/marigold)
Marigold is a script built for generating basic CRUD test for an API. Focus is on generating endpoint tests for Go. The test will be built out to support Ginkgo and Gomega. Marigold will support Javascript, Elixir, and Ruby in the future.
## Installation
```bash
gem install marigold
```
## Generating test
Assuming that you have some `*.go` files in your working directory, Marigold will loop through each one of the files and create a new file with the format `_test.go`. After generating test into each file, Marigold will call `go fmt` to format the Go code.
```bash
$ ls
user.go post.go
$ marigold
$ ls
user.go user_test.go post.go post_test.go
```
**user.go**
```go
package main_test
import (
"bytes"
"net/http"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("User", func() {
var client = http.Client{}
Describe("POST /api/users", func() {
Context("with wrong user attributes", func() {
It("responds with a 400", func() {
reader := bytes.NewReader([]byte(`{
TODO: JSON Object to POST with
}`))
req, err := http.NewRequest("POST", _SERVER_+"/api/users", reader)
Expect(err).To(BeNil())
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode).To(Equal(http.StatusBadRequest))
})
})
Context("with correct user attributes", func() {
It("responds with a 201", func() {
reader := bytes.NewReader([]byte(`{
TODO: JSON Object to POST with
}`))
req, err := http.NewRequest("POST", _SERVER_+"/api/users", reader)
Expect(err).To(BeNil())
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode).To(Equal(http.StatusCreated))
})
})
})
...
```
To see entire example, check the examples directory
## Support
Order of Completion
- [x] Go (Ginkgo/Gomega)
- [ ] Javascript
- [ ] Elixir
- [ ] Ruby