• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

renatomassaro / FeebDB / 472957ede3b20cca285821dedb7ec2cc8604d86c

24 Jun 2025 01:30PM UTC coverage: 85.931% (-0.06%) from 85.99%
472957ede3b20cca285821dedb7ec2cc8604d86c

push

github

web-flow
Merge pull request #26 from renatomassaro/allow-enum-values-to-be-defined-as-a-function

Allow Enum values to be defined as a function

1 of 1 new or added line in 1 file covered. (100.0%)

1 existing line in 1 file now uncovered.

1246 of 1450 relevant lines covered (85.93%)

19863.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
/test/support/db/setup.ex
1
defmodule Test.Feeb.DB.Setup do
2
  alias Test.Feeb.DB.Prop
3
  alias Feeb.DB.{Query, SQLite}
4

5
  def test_conn(path) do
6
    {:ok, conn} = SQLite.open(path)
11✔
7
    "PRAGMA synchronous=OFF" |> SQLite.raw2!(conn)
11✔
8
    "PRAGMA journal_mode=memory" |> SQLite.raw2!(conn)
11✔
9
    conn
11✔
10
  end
11

12
  def new_test_db(context, opts \\ []) do
13
    prop_path = Prop.get_path(context)
204✔
14
    shard_id = Keyword.get(opts, :shard_id, gen_shard_id())
204✔
15

16
    base_test_db_path = "#{Test.Feeb.DB.test_dbs_path()}/#{context}"
204✔
17
    test_db_path = "#{base_test_db_path}/#{shard_id}.db"
204✔
18

19
    File.mkdir_p!(base_test_db_path)
204✔
20
    File.cp!(prop_path, test_db_path)
204✔
21
    {:ok, shard_id, test_db_path}
204✔
22
  end
23

24
  def compile_test_queries do
25
    domains = [:friends, :users, :posts]
189✔
26

27
    try_and_compile = fn domain ->
189✔
28
      try do
567✔
29
        Query.fetch_all!({:test, domain})
567✔
30
      rescue
31
        _ ->
UNCOV
32
          Query.compile("priv/test/queries/test/#{domain}.sql", {:test, domain})
×
33
      end
34
    end
35

36
    Enum.each(domains, fn domain -> try_and_compile.(domain) end)
189✔
37
  end
38

39
  defp gen_shard_id do
40
    # And here I am thinking we wouldn't ever hit different tests with the same shard_id. I was very
41
    # wrong. This happened when the test suite had 180 tests. Hence the usage of `strong_rand_bytes`
42
    :crypto.strong_rand_bytes(8)
43
    |> :binary.decode_unsigned()
44
    |> rem(1_000_000)
204✔
45
  end
46
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc