Skip to content

Magically summon Ecto fixtures w/ fake data for your tests.

Notifications You must be signed in to change notification settings

devoutsalsa/ecto_summoner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EctoSummoner

Magically summon Ecto fixtures w/ fake data for your tests.

Entity relationship diagram

Example For Single Record w/ Only String Types & No Associations

iex> EctoSummoner.summon!(:log)
%Log{log: "log-0"}

Example For Multiple Records w/ Only String Types & No Associations

iex> EctoSummoner.summon!(:logs)
[%Log{log: "log-9"}, %Log{log: "log-10"}, %Log{log: "log-11"}]

Example With Associations

Relationships:

  • GameConsole <- one to one -> Warranty
  • GameConsole <- one to many -> Peripheral
  • RegisteredOwner <- one to many -> GameConsole
  • Manufacturer <- one to many -> GameConsoles
  • Manufacturer <- many to many -> RegisteredOwner

Command

# This one command generates:
# - 1 GameConsole
# - 2+ Peripherals for the GameConsole
# - 1 Warranty for the GameConsole
# - 1 RegisteredOwner for the GameConsole
# - 1 Manufacturer for the GameConsole,
#   2+ RegisteredOwners for the Manufacturer,
#   2+ Manufacturers for each Registered Owner,
#   and 1 GameConsole for each Manufacturer
summon!(
  game_console: [
    :peripherals, 
    :warranty, 
    :registered_owner, 
    manufacturer: [
      registered_owners: [
        manufacturers: :game_console
      ]
    ]
  ]
)

Installation

If available in Hex, the package can be installed by adding ecto_summoner to your list of dependencies in mix.exs:

def deps do
  [
    {:ecto_summoner, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ecto_summoner.

About

Magically summon Ecto fixtures w/ fake data for your tests.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages