utils.TestFileGetContents   B
last analyzed

Complexity

Conditions 7

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 13
nop 1
dl 0
loc 22
rs 8
c 0
b 0
f 0
1
package utils
2
3
import (
4
	"testing"
5
)
6
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
		}
30
	})
31
}
32