Conditions | 7 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | package utils |
||
7 | func TestFileGetContents(t *testing.T) { |
||
8 | t.Run("returns file content", func(t *testing.T) { |
||
9 | result := FileGetContents("../storage/test_files/small_text") |
||
10 | |||
11 | if result != "Hello world" { |
||
12 | t.Errorf("The value of result variable must be `Hello world` but %v returned", result) |
||
13 | } |
||
14 | }) |
||
15 | |||
16 | t.Run("returns empty string if file is empty", func(t *testing.T) { |
||
17 | result := FileGetContents("../storage/test_files/empty") |
||
18 | |||
19 | if result != "" { |
||
20 | t.Error("The value of result variable must be empty string") |
||
21 | } |
||
22 | }) |
||
23 | |||
24 | t.Run("returns empty string if does not exist", func(t *testing.T) { |
||
25 | result := FileGetContents("nostradamus") |
||
26 | |||
27 | if result != "" { |
||
28 | t.Error("FileGetContents must return empty string because file doesn't exist") |
||
29 | } |
||
32 |