Passed
Push — master ( 23e371...7b0ca1 )
by Stefano
02:15
created

pkg/common/urlpath/pathutil_test.go   A

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 30
dl 0
loc 53
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A urlpath.TestHasExtension 0 45 3
1
package urlpath
2
3
import (
4
	"testing"
5
6
	"github.com/stretchr/testify/assert"
7
)
8
9
func TestHasExtension(t *testing.T) {
10
	testCases := []struct {
11
		path           string
12
		expectedResult bool
13
	}{
14
		{
15
			path:           "images/image.jpg",
16
			expectedResult: true,
17
		},
18
		{
19
			path:           "file.pdf",
20
			expectedResult: true,
21
		},
22
		{
23
			path:           "home/page.php",
24
			expectedResult: true,
25
		},
26
		{
27
			path:           "src/code.cpp",
28
			expectedResult: true,
29
		},
30
		{
31
			path:           "src/code.h",
32
			expectedResult: true,
33
		},
34
		{
35
			path:           "folder/script.sh",
36
			expectedResult: true,
37
		},
38
		{
39
			path:           "myfile",
40
			expectedResult: false,
41
		},
42
		{
43
			path:           "myfolder/myfile",
44
			expectedResult: false,
45
		},
46
	}
47
48
	for _, tc := range testCases {
49
		tc := tc
50
		t.Run(tc.path, func(t *testing.T) {
51
			t.Parallel()
52
53
			assert.Equal(t, tc.expectedResult, HasExtension(tc.path))
54
		})
55
	}
56
}
57