-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparams_test.go
More file actions
34 lines (29 loc) · 697 Bytes
/
params_test.go
File metadata and controls
34 lines (29 loc) · 697 Bytes
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
package hypixel
import (
"testing"
)
func TestParams_String(t *testing.T) {
params := Params{
"key1": "value1",
}
t.Run("Delete key", func(t *testing.T) {
params.Del("key1")
if params.Has("key1") {
t.Errorf("expected to not have key1")
}
})
t.Run("Set and Get key", func(t *testing.T) {
params.Set("key2", "value2")
if params.Get("key2") != "value2" {
t.Errorf("expected 'value2', got %s", params.Get("key2"))
}
})
t.Run("Generate URL string", func(t *testing.T) {
url := "https://example.com/v1"
full := params.String(url)
expected := "https://example.com/v1?key2=value2"
if full != expected {
t.Errorf("expected %s, got %s", expected, full)
}
})
}