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

util_test.go   A

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 26
dl 0
loc 41
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A main.TestFilterIpV4 0 1 1
A main.TestFolderOfNormal 0 5 2
A main.TestFolderOfPanic2 0 5 2
A main.TestFolderOfPanic1 0 8 3
A main.TestFolderWithoutParams 0 5 2
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