@@ -24,39 +24,41 @@ void main() {
2424 var obfuscatedToken = _obfuscateToken (token);
2525 final keyBase64 = obfuscatedToken.keyBase64;
2626 final dataBase64 = obfuscatedToken.dataBase64;
27- print ("Store this in generator/lib/${ObjectBoxAnalysis .tokenFilePath }:" );
27+ print (
28+ "Store this in generator/lib/${ObjectBoxAnalysis .defaultTokenFilePath }:" );
2829 print ("$keyBase64 \n $dataBase64 " );
2930
30- final decryptedToken =
31- ObjectBoxAnalysis () .decryptAndVerifyToken (keyBase64, dataBase64);
31+ final decryptedToken = ObjectBoxAnalysis (debug : true )
32+ .decryptAndVerifyToken (keyBase64, dataBase64);
3233 expect (decryptedToken, equals (token));
3334 }, skip: true );
3435
3536 test ("send test event" , () async {
36- // Create a token file just for this test (delete right after to avoid
37- // CI sending events).
37+ // Create a token file just for this test
3838 final token = Platform .environment["DART_ANALYSIS_TOKEN" ];
3939 if (token == null ) {
4040 markTestSkipped ("DART_ANALYSIS_TOKEN not set" );
4141 return ;
4242 }
4343 var obfuscatedToken = _obfuscateToken (token);
44- final tokenFile = File ("lib/${ObjectBoxAnalysis .tokenFilePath }" );
44+ // Use a token file different from the default to prevent parallel running
45+ // tests from sending events.
46+ final tokenFilePath = 'assets/test-analysis-token.txt' ;
47+ final tokenFile = File ("lib/$tokenFilePath " );
4548 await tokenFile.writeAsString (
4649 "${obfuscatedToken .keyBase64 }\n ${obfuscatedToken .dataBase64 }" );
50+ addTearDown (() async => tokenFile.delete ());
4751
4852 final testPubspec = Pubspec ("test" , dependencies: {
4953 "flutter" : SdkDependency ("flutter" ),
5054 "objectbox" : HostedDependency (version: VersionConstraint .parse ("^1.2.3" ))
5155 });
5256
53- final analysis = ObjectBoxAnalysis ();
57+ final analysis =
58+ ObjectBoxAnalysis (tokenFilePath: tokenFilePath, debug: true );
5459 final event = analysis.buildEvent ("Test Event" , "test-uid" , testPubspec);
5560 final response = await analysis.sendEvent (event);
5661
57- // Delete token before test may fail to ensure CI does not send events.
58- await tokenFile.delete ();
59-
6062 expect (response! .statusCode, 200 );
6163 expect (response.body, "1" );
6264 });
0 commit comments