@@ -21,6 +21,7 @@ import (
2121 "path/filepath"
2222 "runtime"
2323 "strings"
24+ "sync/atomic"
2425 "testing"
2526 "time"
2627
@@ -430,19 +431,19 @@ var tokenCounter int64
430431
431432func getTokenForLoggedInUser (t testing.TB , session * TestSession ) string {
432433 t .Helper ()
433- tokenCounter ++
434434 req := NewRequest (t , "GET" , "/user/settings/applications" )
435435 resp := session .MakeRequest (t , req , http .StatusOK )
436436 doc := NewHTMLParser (t , resp .Body )
437437 req = NewRequestWithValues (t , "POST" , "/user/settings/applications" , map [string ]string {
438438 "_csrf" : doc .GetCSRF (),
439- "name" : fmt .Sprintf ("api-testing-token-%d" , tokenCounter ),
439+ "name" : fmt .Sprintf ("api-testing-token-%d" , atomic . AddInt64 ( & tokenCounter , 1 ) ),
440440 })
441441 resp = session .MakeRequest (t , req , http .StatusSeeOther )
442442 req = NewRequest (t , "GET" , "/user/settings/applications" )
443443 resp = session .MakeRequest (t , req , http .StatusOK )
444444 htmlDoc := NewHTMLParser (t , resp .Body )
445445 token := htmlDoc .doc .Find (".ui.info p" ).Text ()
446+ assert .NotEmpty (t , token )
446447 return token
447448}
448449
0 commit comments