forked from parroty/excoveralls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cover_test.exs
46 lines (37 loc) · 1.62 KB
/
cover_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
defmodule CoverTest do
use ExUnit.Case
import ExUnit.CaptureIO
alias ExCoveralls.Cover
test "module path returns relative path" do
assert(Cover.module_path(ExCoveralls) == "lib/excoveralls.ex")
end
test "has_compile_info?/1 with uncompiled module raises warning and returns false" do
assert capture_io(:stderr, fn ->
refute Cover.has_compile_info?(Foo)
end) =~ "[warning] skipping the module 'Elixir.Foo' because source information for the module is not available."
end
test "has_compile_info?/1 with missing source file raises warning and returns false" do
assert Cover.has_compile_info?(TestMissing)
path = Cover.module_path(TestMissing)
backup_path = "test/fixtures/test_missing.bkp"
on_exit({:clean_up, backup_path}, fn ->
File.copy!(backup_path, path)
File.rm!(backup_path)
end)
File.copy!(path, backup_path)
File.rm!(path)
refute File.exists?(path)
assert capture_io(:stderr, fn ->
refute Cover.has_compile_info?(TestMissing)
end) =~ "[warning] skipping the module 'Elixir.TestMissing' because source file with '#{__DIR__}/fixtures/test_missing.ex' path does not exist"
end
test "has_compile_info?/1 with a mocked module raises warning and returns false" do
:ok = :meck.new(MockedModule, [:non_strict])
assert capture_io(:stderr, fn ->
refute Cover.has_compile_info?(MockedModule)
end) =~ "[warning] skipping the module 'Elixir.MockedModule' because source information for the module is not available."
end
test "has_compile_info?/1 with existing source returns true" do
assert Cover.has_compile_info?(TestMissing)
end
end