Mainly this package was created for testing purposes, to give the ability to seed a database with records from simple .yaml files. Polluter respects the order in files, so you can handle foreign_keys just by placing them in the right order.
package main
import "github.com/romanyx/polluter"
const input = `
roles:
- name: User
users:
- name: Roman
role_id: 1
`
func TestX(t *testing.T) {
db := prepareMySQL(t)
defer db.Close()
p := polluter.New(polluter.MySQLEngine(db))
if err := p.Pollute(strings.NewReader(input)); err != nil {
t.Fatalf("failed to pollute: %s", err)
}
....
}
See examples of usage with parallel testing.
Make shure to start docker before testing.
go test
- MySQL
- Postgres
- Redis
Please feel free to submit issues, fork the repository and send pull requests!