Skip to content

Junk is a module for generating Junk data in your tests

License

Notifications You must be signed in to change notification settings

petermueller/ex_junk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Junk

Junk is a module for generating Junk data in your tests. For when you don't care about the content, just that it has the right 'shape'. It is inspired by Dave Brady's rspec-junklet

Build Status

Installation

The package can be installed by adding ex_junk to your list of dependencies in mix.exs:

def deps do
  [{:ex_junk, "~> 0.1.0", only: :test}]
end

Example

defmodule ExampleTest do
  import Junk 

  test "example test" do
    thing = %{
      name:    junk, # defaults to junk(String)
      some_id: junk(Integer, size: 9)
    }
    struct(SomeThing, thing)
    |> SomeThing.push

    assert SomeThing.pop == thing
  end
end

Usage

Junk.junk                          # "w8eY_L2UHZsPBBSq"
Junk.junk(String)                  # same
Junk.junk(String,  byte_size: 10)  # similar, but shorter
Junk.junk(String,  prefix: "yarp") # "yarp-w8eY_L2UHZsPBBSq..."
Junk.junk(Integer, size: 10)       # 9593685924

Links

Hex - https://hex.pm/packages/ex_junk

About

Junk is a module for generating Junk data in your tests

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages