Project

marigold

0.0
No commit activity in last 3 years
No release in over 3 years
Marigold is a script built for generating basic CRUD test for an API. Focus is on generating endpoint tests for Go. Because of this, version 1.0.0 will be able to build very simple endpoint test in Go. The test will be built out to support Ginkgo and Gomega. Marigold will support Javascript, Elixir, and Ruby in the future.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Marigold

Gem Version

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

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 <base_name>_test.go. After generating test into each file, Marigold will call go fmt to format the Go code.

$ ls
user.go post.go

$ marigold
$ ls
user.go user_test.go post.go post_test.go

user.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

  • Go (Ginkgo/Gomega)
  • Javascript
  • Elixir
  • Ruby