-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebarchive_test.go
More file actions
54 lines (43 loc) · 1.19 KB
/
webarchive_test.go
File metadata and controls
54 lines (43 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// The full code is still under testing
package webarchive
import (
"net/url"
"github.com/stretchr/testify/assert"
"testing"
)
func TestHasParamWithParam(t *testing.T) {
// Create a URL with parameters
u, err := url.Parse("https://example.com/path?param=value")
assert.NoError(t, err)
// Call the hasParam function
result := hasParams(u)
// Assertions
assert.True(t, result)
}
func TestHasParamWithoutParam(t *testing.T) {
// Create a URL without parameters
u, err := url.Parse("https://example.com/path")
assert.NoError(t, err)
// Call the hasParam function
result := hasParams(u)
// Assertions
assert.False(t, result)
}
func TestMethodHasParam(t *testing.T) {
// Create an instance of the Result
result := &Result{
URLs: []*url.URL{
{RawQuery: "param1=value1"},
{RawQuery: ""},
{RawQuery: "param2=value2"},
},
}
filteredURLs, err := result.HasParams()
// Assert that no error
assert.NoError(t, err)
// Assert that the number of filteredURLs is exepected
assert.Len(t, filteredURLs, 2)
// Assert that the filtered parameters is actually valid
assert.Equal(t, "param1=value1", filteredURLs[0].RawQuery)
assert.Equal(t, "param2=value2", filteredURLs[1].RawQuery)
}