File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
Tests/AlgoliaSearchClientTests/Integration Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,11 @@ class AnalyticsIntegrationTests: OnlineTestCase {
2525 }
2626
2727 func abTesting( ) throws {
28-
28+
2929 let analyticsClient = AnalyticsClient ( appID: client. applicationID, apiKey: client. apiKey)
3030
31- let index1 = client. index ( withName: " ab_testing " )
32- let index2 = client. index ( withName: " ab_testing_dev " )
31+ let index1 = client. index ( withName: IndexName ( rawValue : " \( uniquePrefix ( ) ) _ab_testing " ) )
32+ let index2 = client. index ( withName: IndexName ( rawValue : " \( uniquePrefix ( ) ) _ab_testing_dev " ) )
3333
3434 let save1 = try index1. saveObject ( [ " objectID " : " one " ] as JSON )
3535 try AssertWait ( save1)
@@ -71,7 +71,7 @@ class AnalyticsIntegrationTests: OnlineTestCase {
7171 func aaTesting( ) throws {
7272
7373 let analyticsClient = AnalyticsClient ( appID: client. applicationID, apiKey: client. apiKey)
74- let index = client. index ( withName: " aa_testing " )
74+ let index = client. index ( withName: IndexName ( rawValue : " \( uniquePrefix ( ) ) _aa_testing " ) )
7575
7676 let saveObject = try index. saveObject ( [ " objectID " : " one " ] )
7777 try AssertWait ( saveObject)
Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ class OnlineTestCase: XCTestCase {
2626 var indexNameSuffix : String ? {
2727 return nil
2828 }
29+
30+ func uniquePrefix( ) -> String {
31+ let dateFormatter = DateFormatter ( )
32+ dateFormatter. dateFormat = " YYYY-MM-DD_HH:mm:ss "
33+ let dateString = dateFormatter. string ( from: . init( ) )
34+ return " swift_ \( dateString) _ \( NSUserName ( ) . description) "
35+ }
2936
3037 override func setUpWithError( ) throws {
3138
@@ -36,14 +43,10 @@ class OnlineTestCase: XCTestCase {
3643 }
3744
3845 client = SearchClient ( appID: credentials. applicationID, apiKey: credentials. apiKey)
39-
4046 let className = String ( reflecting: type ( of: self ) ) . components ( separatedBy: " . " ) . last!
4147 let functionName = invocation!. selector. description
4248 let indexNameSuffix = self . indexNameSuffix ?? " \( className) . \( functionName) "
43- let dateFormatter = DateFormatter ( )
44- dateFormatter. dateFormat = " YYYY-MM-DD_HH:mm:ss "
45- let dateString = dateFormatter. string ( from: . init( ) )
46- let indexName = IndexName ( stringLiteral: " swift_ \( dateString) _ \( NSUserName ( ) . description) _ \( indexNameSuffix) " )
49+ let indexName = IndexName ( stringLiteral: " \( uniquePrefix ( ) ) _ \( indexNameSuffix) " )
4750 index = client. index ( withName: indexName)
4851
4952 try index. delete ( )
You can’t perform that action at this time.
0 commit comments