Passed
Push — master ( 18f180...614694 )
by Abouzar
01:00 queued 14s
created

main.TestFolderWithoutParams   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
package main
2
3
import (
4
	"path/filepath"
5
	"testing"
6
)
7
8
func TestFilterIpV4(t *testing.T) {
9
}
10
11
func TestFolderOfPanic1(t *testing.T) {
12
	defer func() {
13
		if r := recover(); r == nil {
14
			t.Errorf("The code did not panic")
15
		}
16
	}()
17
	url := "http://foo.bar/.."
18
	FolderOf(url)
19
}
20
21
func TestFolderOfPanic2(t *testing.T) {
22
	url := "http://foo.bar/../../../foobar"
23
	u := FolderOf(url)
24
	if filepath.Base(u) != "foobar" {
25
		t.Fatalf("url of return incorrect value")
26
	}
27
}
28
29
func TestFolderOfNormal(t *testing.T) {
30
	url := "http://foo.bar/file"
31
	u := FolderOf(url)
32
	if filepath.Base(u) != "file" {
33
		t.Fatalf("url of return incorrect value")
34
	}
35
}
36
37
func TestFolderWithoutParams(t *testing.T) {
38
	url := "http://foo.bar/file?param=value"
39
	u := FolderOf(url)
40
	if filepath.Base(u) != "file" {
41
		t.Fatalf("url of return incorrect value")
42
	}
43
}
44