@@ -6,6 +6,10 @@ import (
66 "testing"
77)
88
9+ const (
10+ ascaLocationKey = "asca-location"
11+ )
12+
913func TestCleanURL_CleansCorrectly (t * testing.T ) {
1014 uri := "https://codebashing.checkmarx.com/courses/java/////lessons/sql_injection/////"
1115 want := "https://codebashing.checkmarx.com/courses/java/lessons/sql_injection"
@@ -170,7 +174,7 @@ func clearOptionalParams() {
170174
171175func TestSetAndGetAllowedKey (t * testing.T ) {
172176 clearOptionalParams ()
173- key := "asca-location"
177+ key := ascaLocationKey
174178 value := "location-1"
175179
176180 SetOptionalParam (key , value )
@@ -206,23 +210,17 @@ func TestSetWithTrimmedKeyBehavior(t *testing.T) {
206210 clearOptionalParams ()
207211
208212 originalKey := " asca-location "
209- trimmedKey := "asca-location"
213+ trimmedKey := ascaLocationKey
210214 value := "trimmed-value"
211215
212216 SetOptionalParam (originalKey , value )
213217
214- if ! hasOptionalParam (originalKey ) {
215- t .Fatalf ("expected hasOptionalParam(%q) to be true" , originalKey )
216- }
217218 if got := GetOptionalParam (originalKey ); got != value {
218219 t .Fatalf ("expected GetOptionalParam(%q) == %q, got %q" , originalKey , value , got )
219220 }
220221
221- if hasOptionalParam (trimmedKey ) {
222- t .Fatalf ("did not expect hasOptionalParam(%q) to be true" , trimmedKey )
223- }
224- if got := GetOptionalParam (trimmedKey ); got != "" {
225- t .Fatalf ("expected GetOptionalParam(%q) == empty, got %q" , trimmedKey , got )
222+ if got := GetOptionalParam (trimmedKey ); got != value {
223+ t .Fatalf ("expected GetOptionalParam(%q) == %q, got %q" , originalKey , value , got )
226224 }
227225}
228226
@@ -235,16 +233,16 @@ func TestConcurrentSetOptionalParam(t *testing.T) {
235233 wg .Add (1 )
236234 go func (i int ) {
237235 defer wg .Done ()
238- SetOptionalParam ("asca-location" , "v" )
236+ SetOptionalParam (ascaLocationKey , "v" )
239237 SetOptionalParam ("not-allowed" , "x" )
240238 }(i )
241239 }
242240 wg .Wait ()
243241
244- if ! hasOptionalParam ("asca-location" ) {
242+ if ! hasOptionalParam (ascaLocationKey ) {
245243 t .Fatalf ("expected hasOptionalParam(%q) to be true after concurrent sets" , "asca-location" )
246244 }
247245 if GetOptionalParam ("asca-location" ) != "v" {
248- t .Fatalf ("expected GetOptionalParam(%q) == %q" , "asca-location" , "v" )
246+ t .Fatalf ("expected GetOptionalParam(%q) == %q" , ascaLocationKey , "v" )
249247 }
250248}
0 commit comments