Here are my tables
Load them [with data] for me
I don't care how
Mock-data is the result of a Pivotal internal hackathon in July 2017. The idea behind it is to allow users to test database queries with sets of fake data in any pre-defined table.
With Mock-data users can have
n
number of table with n
number of columnrealistic
data to be loaded onto the tableAn ideal environment to make Mock-data work without any errors would be
However, please DO MAKE SURE TO TAKE A BACKUP of your database before you mock data in it as it has not been tested extensively.
Check on the "Known Issues" section below for more information about current identified bugs.
Mock-data idea is to generate fake data in new test cluster, and it is NOT TO BE USED IN PRODUCTION ENVIRONMENTS. Please ensure you have a backup of your database before running Mock-data in an environment you can't afford losing.
$HOME/mock
$ mock --help
This program generates fake data into a postgres database cluster.
PLEASE DO NOT run on a mission critical databases
Usage:
mock [flags]
mock [command]
Available Commands:
custom Controlled mocking of tables
database Mock at database level
help Help about any command
schema Mock at schema level
tables Mock at table level
Flags:
-a, --address string Hostname where the postgres database lives
-d, --database string Database to mock the data
-q, --dont-prompt Run without asking for confirmation
-h, --help help for mock
-i, --ignore Ignore checking and fixing constraints
-w, --password string Password for the user to connect to database
-p, --port int Port number of the postgres database
-r, --rows int Total rows to be faked or mocked (default 10)
--uri string Postgres connection URI, eg. postgres://user:pass@host:=port/db?sslmode=disable
-u, --username string Username to connect to the database
-v, --verbose Enable verbose or debug logging
--version version for mock
Use "mock [command] --help" for more information about a command.
Download the latest release for your OS & Architecture and you're ready to go!
[Optional] You can copy the mock program to the PATH folder, so that you can use the mock from anywhere in the terminal, for eg.s
cp mock-darwin-amd64-v2.0 /usr/local/bin/mock
chmod +x /usr/local/bin/mock
provided /usr/local/bin
is part of the $PATH environment variable.
docker pull ghcr.io/faisaltheparttimecoder/mock-data:latest
docker image tag ghcr.io/faisaltheparttimecoder/mock-data mock
mkdir /tmp/mock
docker run -v /tmp/mock:/home/mock [docker-image-tag] [subcommand] <flags...>
eg.s
docker run -v /tmp/mock:/home/mock mock database -f -u postgres -d demodb
host.docker.internal
as shown in the below command
docker run -v /tmp/mock:/home/mock [docker-image-tag] [subcommand] -a host.docker.internal <flags...>
eg.s
docker run -v /tmp/mock:/home/mock mock database -f -a host.docker.internal -u postgres -d demodb
.zshrc
echo alias mock=\"docker run -it -v /tmp/mock:/home/mock ghcr.io/faisaltheparttimecoder/mock-data:latest\" >> ~/.zshrc
source ~/.zshrc
mock tables -t "public.gardens" --uri="postgres://pg_user:mypassword@myhost:5432/database_name?sslmode=disable"
Here is a simple demo of how the tool works, provide us your table and we will load the data for you
For more examples how to use the tool, please check out the wiki page for categories like
custom
subcommand to control the data being insertedcustom
sub command to define the data to be inserted to the column with check constraintscustom
sub command to control the data for that custom data typesYou can sumbit issues or pull request via github and we will try our best to fix them.
To customize this repository, follow the steps
export GOPATH=<path to the clone repository>
go mod vendor
make install_postgres
make start_postgres
make stop_postgres
make uninstall_postgres
go run . <commands> <flags.........>
golangci-lint run
to install golangci-lint check here, config file .golangci.yml
has been provided with this repo
# Edit the database environment variables on the "Makefile"
make unit_tests
make integration_tests
make tests # Runs the above two test simultaneously
make build
--- HAPPY HACKING ---
Faisal Ali |
Jan Piotrowski |
Matt Song |
Aitor Pérez Cedres |
Andreas Gangsø |
Artem |
Juan José Ramos |
Miguel Fernández |
The Project is licensed under MIT