Protox v0.15.2 Protox.RandomInit

Provides a way to randomly init a message. Useful for tests or benchmarks.

Summary

Functions

Generates a randomly initialized message using its definition. It’s possible to give a seed as the second parameter to get reproducible results

Functions

generate(mod, seed \\ nil)
generate(atom, nil | integer) :: struct

Generates a randomly initialized message using its definition. It’s possible to give a seed as the second parameter to get reproducible results.

Example

defmodule Definitions do
 use Protox, schema: """
   syntax = "proto3";

   message Baz {
   }

   message Foo {
     int32 a = 1;
     map<int32, Baz> b = 2;
   }
 """
end

iex> Protox.RandomInit.generate(Foo, 42)
%Foo{a: -97, b: %{-83 => %Baz{}, -46 => %Baz{}}}