...

Source file src/gitlab.hexacode.org/go-libs/hctypes/QueryString_test.go

Documentation: gitlab.hexacode.org/go-libs/hctypes

     1  package hctypes_test
     2  
     3  import (
     4  	"net/url"
     5  	"testing"
     6  
     7  	"gitlab.hexacode.org/go-libs/hctypes"
     8  )
     9  
    10  func TestDictToQueryString(t *testing.T) {
    11  	inputDict := hctypes.Dict{
    12  		"key1": "value1",
    13  		"key2": hctypes.List{
    14  			42,
    15  		},
    16  	}
    17  
    18  	expectedQueryString := url.PathEscape("key1=value1&key2[0]=42")
    19  	actualQueryString := inputDict.ToQueryString().Encode()
    20  
    21  	if expectedQueryString != actualQueryString {
    22  		t.Errorf("Expected: %s, Got: %s", expectedQueryString, actualQueryString)
    23  	}
    24  }
    25  

View as plain text