pkg/scan/client/cookie/jar_test.go   A
last analyzed

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A cookie_test.TestStatelessJarShouldBeStateless 0 26 1
A cookie_test.TestStatelessJarShouldWorkWithNilCookies 0 2 1
1
package cookie_test
2
3
import (
4
	"net/http"
5
	"net/url"
6
	"testing"
7
8
	"github.com/stefanoj3/dirstalk/pkg/scan/client/cookie"
9
	"github.com/stretchr/testify/assert"
10
)
11
12
func TestStatelessJarShouldWorkWithNilCookies(t *testing.T) {
13
	assert.Nil(t, cookie.NewStatelessJar(nil).Cookies(nil))
14
}
15
16
func TestStatelessJarShouldBeStateless(t *testing.T) {
17
	cookies := []*http.Cookie{
18
		{
19
			Name:  "a_cookie_name",
20
			Value: "a_cookie_value",
21
		},
22
	}
23
24
	jar := cookie.NewStatelessJar(cookies)
25
26
	u, err := url.Parse("http://github.com/stefanoj3")
27
	assert.NoError(t, err)
28
29
	assert.Equal(t, cookies, jar.Cookies(u))
30
31
	jar.SetCookies(
32
		u,
33
		[]*http.Cookie{
34
			{
35
				Name:  "another_cookie_name",
36
				Value: "another_cookie_value",
37
			},
38
		},
39
	)
40
41
	assert.Equal(t, cookies, jar.Cookies(u))
42
}
43