github.com/clubpay/ronykit/kit@v0.14.4-0.20240515065620-d0dace45cbc7/stub/utils_test.go (about)

     1  package stub_test
     2  
     3  import (
     4  	"github.com/clubpay/ronykit/kit/stub"
     5  	. "github.com/onsi/ginkgo/v2"
     6  	. "github.com/onsi/gomega"
     7  )
     8  
     9  var keyValues = func(in string) string {
    10  	switch in {
    11  	case "p1":
    12  		return "value1"
    13  	case "p2":
    14  		return "value2"
    15  	case "p3":
    16  		return "value3"
    17  	}
    18  
    19  	return in
    20  }
    21  
    22  var _ = DescribeTable(
    23  	"Fill URL Params",
    24  	func(in, out string, f func(string) string) {
    25  		Expect(stub.FillParams(in, f)).To(Equal(out))
    26  	},
    27  	Entry("",
    28  		"/some/{p1}/{p2}?something={p3}&boolean",
    29  		"/some/value1/value2?something=value3&boolean",
    30  		keyValues,
    31  	),
    32  	Entry("",
    33  		"/some/{p1}/{p2}?something={p3}&boolean",
    34  		"/some/value1/value2?something=value3&boolean",
    35  		keyValues,
    36  	),
    37  	Entry("",
    38  		"/some/{p1}{p2}/?something={p3}&boolean",
    39  		"/some/value1value2/?something=value3&boolean",
    40  		keyValues,
    41  	),
    42  	Entry("",
    43  		"/some/{p1}",
    44  		"/some/value1",
    45  		keyValues,
    46  	),
    47  )