Skip to content
/ poptest Public

A utility package that can be used when testing with gobuffalo pop connection.

License

Notifications You must be signed in to change notification settings

royge/poptest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

poptest

Go Go Report Card

A utility package that can be used when testing with gobuffalo pop connection.

The primary goal of this package is to override the database name from the database.yml programatically.

How To Use

go get github.com/royge/poptest

Example:

import (
	"fmt"
	"strings"

	"github.com/royge/poptest"

	pop "github.com/gobuffalo/pop/v6"
)

// ExampleDeets show the primary purpose of this package.
// You can see that I override the test-mydb database name from database.yml
// with random-db-name.
func ExampleDeets() {
	deets, err := poptest.Deets("test", func(d *pop.ConnectionDetails) error {
		fmt.Println("original:", d.URL)

		name := "random-db-name"
		d.URL = strings.Replace(d.URL, "test-mydb", name, 1)

		return nil
	})
	if err != nil {
		panic("don't panic")
	}

	fmt.Println("new:", deets.URL)

	// Output:
	// original: postgres://postgres:password@127.0.0.1:5432/test-mydb?sslmode=disable
	// new: postgres://postgres:password@127.0.0.1:5432/random-db-name?sslmode=disable
}

About

A utility package that can be used when testing with gobuffalo pop connection.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages