@@ -1067,7 +1067,7 @@ - (void)testFetchEntryEqualToField {
1067
1067
1068
1068
ContentType* csForm = [csStack contentTypeWithName: @" source" ];
1069
1069
Query* csQuery = [csForm query ];
1070
- __block NSString *objectValue = @" source " ;
1070
+ __block NSString *objectValue = @" source1 " ;
1071
1071
[csQuery whereKey: @" title" equalTo: objectValue];
1072
1072
1073
1073
[csQuery find: ^(ResponseType type, QueryResult *result, NSError *error) {
@@ -2013,7 +2013,7 @@ - (void)testFetchTags {
2013
2013
ContentType* csForm = [csStack contentTypeWithName: @" source" ];
2014
2014
2015
2015
Query* csQuery = [csForm query ];
2016
- __block NSMutableArray *tags = [NSMutableArray arrayWithArray: @[@" tags1 " ,@" tags2 " ]];
2016
+ __block NSMutableArray *tags = [NSMutableArray arrayWithArray: @[@" tag1 " ,@" tag2 " ]];
2017
2017
[csQuery tags: tags];
2018
2018
[csQuery find: ^(ResponseType type, QueryResult *result, NSError *error) {
2019
2019
@@ -2122,7 +2122,7 @@ - (void)testFetchSkipEntries {
2122
2122
2123
2123
ContentType* csForm = [csStack contentTypeWithName: @" source" ];
2124
2124
2125
- __block NSInteger skipObject = 4 ;
2125
+ __block NSInteger skipObject = 1 ;
2126
2126
Query* csQuery = [csForm query ];
2127
2127
[csQuery includeCount ];
2128
2128
[csQuery skipObjects: @(skipObject)];
@@ -2133,7 +2133,7 @@ - (void)testFetchSkipEntries {
2133
2133
XCTFail (@" ~ ERR: %@ " , error.userInfo );
2134
2134
} else {
2135
2135
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" );
2137
2137
}
2138
2138
2139
2139
[expectation fulfill ];
@@ -2545,4 +2545,96 @@ - (void)testVariantHeaders {
2545
2545
}];
2546
2546
}
2547
2547
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
+
2548
2640
@end
0 commit comments