Passed
Push — v3.0.0 ( 671bfc...c3fef3 )
by Serhii
01:12
created

timeago.TestLocationIsSet   A

Complexity

Conditions 4

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 18
dl 0
loc 25
c 0
b 0
f 0
rs 9.5
nop 1
1
package timeago
2
3
import (
4
	"testing"
5
)
6
7
func TestLocationIsSet(t *testing.T) {
8
	cases := []struct {
9
		name   string
10
		loc    string
11
		expect bool
12
	}{
13
		{
14
			name:   "Location is set",
15
			loc:    "Russia/Moscow",
16
			expect: true,
17
		},
18
		{
19
			name:   "Location is not set",
20
			loc:    "",
21
			expect: false,
22
		},
23
	}
24
25
	for _, tc := range cases {
26
		t.Run(tc.name, func(t *testing.T) {
27
			c := NewConfig("ru", tc.loc, []Translation{})
28
			actual := c.LocationIsSet()
29
30
			if actual != tc.expect {
31
				t.Fatalf("Expected %v, but got %v", tc.expect, actual)
32
			}
33
		})
34
	}
35
}
36