File: uri_helper_test.go

package info (click to toggle)
golang-github-viant-toolbox 0.33.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,280 kB
  • sloc: makefile: 16
file content (23 lines) | stat: -rw-r--r-- 616 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package toolbox_test

import (
	"github.com/stretchr/testify/assert"
	"github.com/viant/toolbox"
	"net/url"
	"testing"
)

func Test_QueryValue(t *testing.T) {
	u, err := url.Parse("http://localhost/?k1=v1&k2=2&k3=false")
	assert.Nil(t, err)

	assert.Equal(t, "v1", toolbox.QueryValue(u, "k1", "default"))
	assert.Equal(t, "default", toolbox.QueryValue(u, "k10", "default"))

	assert.Equal(t, 2, toolbox.QueryIntValue(u, "k2", 3))
	assert.Equal(t, 3, toolbox.QueryIntValue(u, "k10", 3))

	assert.Equal(t, false, toolbox.QueryBoolValue(u, "k3", true))
	assert.Equal(t, true, toolbox.QueryBoolValue(u, "k10", true))

}