@@ -18,6 +18,7 @@ import (
1818 "os"
1919 "path/filepath"
2020 "strings"
21+ "sync/atomic"
2122 "testing"
2223 "time"
2324
@@ -263,19 +264,19 @@ var tokenCounter int64
263264
264265func getTokenForLoggedInUser (t testing.TB , session * TestSession ) string {
265266 t .Helper ()
266- tokenCounter ++
267267 req := NewRequest (t , "GET" , "/user/settings/applications" )
268268 resp := session .MakeRequest (t , req , http .StatusOK )
269269 doc := NewHTMLParser (t , resp .Body )
270270 req = NewRequestWithValues (t , "POST" , "/user/settings/applications" , map [string ]string {
271271 "_csrf" : doc .GetCSRF (),
272- "name" : fmt .Sprintf ("api-testing-token-%d" , tokenCounter ),
272+ "name" : fmt .Sprintf ("api-testing-token-%d" , atomic . AddInt64 ( & tokenCounter , 1 ) ),
273273 })
274274 session .MakeRequest (t , req , http .StatusSeeOther )
275275 req = NewRequest (t , "GET" , "/user/settings/applications" )
276276 resp = session .MakeRequest (t , req , http .StatusOK )
277277 htmlDoc := NewHTMLParser (t , resp .Body )
278278 token := htmlDoc .doc .Find (".ui.info p" ).Text ()
279+ assert .NotEmpty (t , token )
279280 return token
280281}
281282
0 commit comments