@@ -24,9 +24,10 @@ import (
2424
2525func TestNormalizeURL (t * testing.T ) {
2626 tests := []struct {
27- name string
28- url string
29- want string
27+ name string
28+ url string
29+ want string
30+ wantErr bool
3031 }{
3132 {
3233 name : "with slash" ,
@@ -43,11 +44,6 @@ func TestNormalizeURL(t *testing.T) {
4344 url : "http://example.com//" ,
4445 want : "http://example.com/" ,
4546 },
46- {
47- name : "empty" ,
48- url : "" ,
49- want : "" ,
50- },
5147 {
5248 name : "oci with slash" ,
5349 url : "oci://example.com/" ,
@@ -58,12 +54,38 @@ func TestNormalizeURL(t *testing.T) {
5854 url : "oci://example.com//" ,
5955 want : "oci://example.com" ,
6056 },
57+ {
58+ name : "url with query" ,
59+ url : "http://example.com?st=pr" ,
60+ want : "http://example.com/?st=pr" ,
61+ },
62+ {
63+ name : "url with slash and query" ,
64+ url : "http://example.com/?st=pr" ,
65+ want : "http://example.com/?st=pr" ,
66+ },
67+ {
68+ name : "empty url" ,
69+ url : "" ,
70+ want : "" ,
71+ },
72+ {
73+ name : "bad url" ,
74+ url : "://badurl." ,
75+ wantErr : true ,
76+ },
6177 }
6278 for _ , tt := range tests {
6379 t .Run (tt .name , func (t * testing.T ) {
6480 g := NewWithT (t )
6581
66- got := NormalizeURL (tt .url )
82+ got , err := NormalizeURL (tt .url )
83+ if tt .wantErr {
84+ g .Expect (err ).To (HaveOccurred ())
85+ return
86+ }
87+
88+ g .Expect (err ).To (Not (HaveOccurred ()))
6789 g .Expect (got ).To (Equal (tt .want ))
6890 })
6991 }
0 commit comments