@@ -1067,7 +1067,7 @@ - (void)testFetchEntryEqualToField {
10671067
10681068 ContentType* csForm = [csStack contentTypeWithName: @" source" ];
10691069 Query* csQuery = [csForm query ];
1070- __block NSString *objectValue = @" source " ;
1070+ __block NSString *objectValue = @" source1 " ;
10711071 [csQuery whereKey: @" title" equalTo: objectValue];
10721072
10731073 [csQuery find: ^(ResponseType type, QueryResult *result, NSError *error) {
@@ -2013,7 +2013,7 @@ - (void)testFetchTags {
20132013 ContentType* csForm = [csStack contentTypeWithName: @" source" ];
20142014
20152015 Query* csQuery = [csForm query ];
2016- __block NSMutableArray *tags = [NSMutableArray arrayWithArray: @[@" tags1 " ,@" tags2 " ]];
2016+ __block NSMutableArray *tags = [NSMutableArray arrayWithArray: @[@" tag1 " ,@" tag2 " ]];
20172017 [csQuery tags: tags];
20182018 [csQuery find: ^(ResponseType type, QueryResult *result, NSError *error) {
20192019
@@ -2122,7 +2122,7 @@ - (void)testFetchSkipEntries {
21222122
21232123 ContentType* csForm = [csStack contentTypeWithName: @" source" ];
21242124
2125- __block NSInteger skipObject = 4 ;
2125+ __block NSInteger skipObject = 1 ;
21262126 Query* csQuery = [csForm query ];
21272127 [csQuery includeCount ];
21282128 [csQuery skipObjects: @(skipObject)];
@@ -2133,7 +2133,7 @@ - (void)testFetchSkipEntries {
21332133 XCTFail (@" ~ ERR: %@ " , error.userInfo );
21342134 } else {
21352135
2136- XCTAssertTrue (([result totalCount ]-skipObject) <= [result getResult ].count , " query should skip 4 objects" );
2136+ XCTAssertTrue (([result totalCount ]-skipObject) <= [result getResult ].count , " query should skip 1 objects" );
21372137 }
21382138
21392139 [expectation fulfill ];
@@ -2545,4 +2545,96 @@ - (void)testVariantHeaders {
25452545 }];
25462546}
25472547
2548+ #pragma mark - Region Support Tests
2549+
2550+ - (void )testDefaultRegion {
2551+ XCTestExpectation *expectation = [self expectationWithDescription: @" DefaultRegionTest" ];
2552+ config = [[Config alloc ] init ];
2553+ Stack *stack = [Contentstack stackWithAPIKey: @" api_key" accessToken: @" delivery_token" environmentName: @" environment" config: config];
2554+
2555+ // Verify default region is US
2556+ XCTAssertEqual (config.region , US, @" Default region should be US" );
2557+ XCTAssertEqualObjects (config.host , @" cdn.contentstack.io" , @" Config host should be US region" );
2558+
2559+ [expectation fulfill ];
2560+ [self waitForExpectationsWithTimeout: kRequestTimeOutInSeconds handler: nil ];
2561+ }
2562+
2563+ - (void )testAllRegionsSupport {
2564+ XCTestExpectation *expectation = [self expectationWithDescription: @" AllRegionsTest" ];
2565+ config = [[Config alloc ] init ];
2566+ Stack *stack = [Contentstack stackWithAPIKey: @" api_key" accessToken: @" delivery_token" environmentName: @" environment" config: config];
2567+
2568+ // Test all regions
2569+ NSDictionary *regionHosts = @{
2570+ @(US): @" cdn.contentstack.io" ,
2571+ @(EU): @" eu-cdn.contentstack.com" ,
2572+ @(AU): @" au-cdn.contentstack.com" ,
2573+ @(AZURE_NA): @" azure-na-cdn.contentstack.com" ,
2574+ @(AZURE_EU): @" azure-eu-cdn.contentstack.com" ,
2575+ @(GCP_NA): @" gcp-na-cdn.contentstack.com" ,
2576+ @(GCP_EU): @" gcp-eu-cdn.contentstack.com"
2577+ };
2578+
2579+ [regionHosts enumerateKeysAndObjectsUsingBlock: ^(NSNumber *region, NSString *expectedHost, BOOL *stop) {
2580+ [config setRegion: region.intValue];
2581+ XCTAssertEqualObjects (config.host , expectedHost,
2582+ @" Config host should be updated for region %@ " , region);
2583+ }];
2584+
2585+ [expectation fulfill ];
2586+ [self waitForExpectationsWithTimeout: kRequestTimeOutInSeconds handler: nil ];
2587+ }
2588+
2589+ - (void )testCustomHostOverride {
2590+ XCTestExpectation *expectation = [self expectationWithDescription: @" CustomHostTest" ];
2591+ config = [[Config alloc ] init ];
2592+ Stack *stack = [Contentstack stackWithAPIKey: @" api_key" accessToken: @" delivery_token" environmentName: @" environment" config: config];
2593+
2594+ // Set custom host
2595+ NSString *customHost = @" custom.contentstack.com" ;
2596+ config.host = customHost;
2597+ XCTAssertEqualObjects (config.host , customHost, @" Config should use custom host" );
2598+
2599+ // Verify region change overrides custom host
2600+ [config setRegion: AU];
2601+ XCTAssertEqualObjects (config.host , @" au-cdn.contentstack.com" , @" Region change should override custom host" );
2602+
2603+ [expectation fulfill ];
2604+ [self waitForExpectationsWithTimeout: kRequestTimeOutInSeconds handler: nil ];
2605+ }
2606+
2607+ - (void )testRegionChangeReflection {
2608+ XCTestExpectation *expectation = [self expectationWithDescription: @" RegionChangeTest" ];
2609+ config = [[Config alloc ] init ];
2610+ Stack *stack = [Contentstack stackWithAPIKey: @" api_key" accessToken: @" delivery_token" environmentName: @" environment" config: config];
2611+
2612+ // Change regions multiple times
2613+ [config setRegion: EU];
2614+ XCTAssertEqualObjects (config.host , @" eu-cdn.contentstack.com" , @" Config should update to EU host" );
2615+
2616+ [config setRegion: AU];
2617+ XCTAssertEqualObjects (config.host , @" au-cdn.contentstack.com" , @" Config should update to AU host" );
2618+
2619+ [config setRegion: US];
2620+ XCTAssertEqualObjects (config.host , @" cdn.contentstack.io" , @" Config should update back to US host" );
2621+
2622+ [expectation fulfill ];
2623+ [self waitForExpectationsWithTimeout: kRequestTimeOutInSeconds handler: nil ];
2624+ }
2625+
2626+ - (void )testAURegion {
2627+ XCTestExpectation *expectation = [self expectationWithDescription: @" DefaultRegionTest" ];
2628+ config = [[Config alloc ] init ];
2629+ [config setRegion: AU];
2630+ Stack *stack = [Contentstack stackWithAPIKey: @" api_key" accessToken: @" delivery_token" environmentName: @" environment" config: config];
2631+
2632+ // Verify default region is US
2633+ XCTAssertEqual (config.region , AU, @" Default region should be AU" );
2634+ XCTAssertEqualObjects (config.host , @" au-cdn.contentstack.com" , @" Config host should be AU region" );
2635+
2636+ [expectation fulfill ];
2637+ [self waitForExpectationsWithTimeout: kRequestTimeOutInSeconds handler: nil ];
2638+ }
2639+
25482640@end
0 commit comments