Skip to content

Commit

Permalink
Unit test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jtung-apple committed Mar 13, 2024
1 parent e444ab9 commit 0ddd4ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ - (BOOL)_deleteAttributeValueForNodeID:(NSNumber *)nodeID endpointID:(NSNumber *
return attributesToReturn;
}

#ifdef DEBUG
- (void)unitTestPruneEmptyStoredAttributesBranches
{
dispatch_sync(_storageDelegateQueue, ^{
[self _pruneEmptyStoredAttributesBranches];
});
}
#endif

- (void)_pruneEmptyStoredAttributesBranches
{
dispatch_assert_queue(_storageDelegateQueue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ - (void)test008_TestDataStoreDirect
[controller.controllerDataStore storeAttributeValues:testAttribute forNodeID:@(2001)];
NSString * testAttributeValueKey = [controller.controllerDataStore _attributeValueKeyForNodeID:@(2001) endpointID:@(1) clusterID:@(1) attributeID:@(1)];
[storageDelegate controller:controller removeValueForKey:testAttributeValueKey securityLevel:MTRStorageSecurityLevelSecure sharingType:MTRStorageSharingTypeNotShared];
[controller.controllerDataStore _pruneEmptyStoredAttributesBranches];
[controller.controllerDataStore unitTestPruneEmptyStoredAttributesBranches];

// Now check the indexes are pruned
NSString * testAttributeIndexKey = [controller.controllerDataStore _attributeIndexKeyForNodeID:@(2001) endpointID:@(1) clusterID:@(1)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)storeAttributeValues:(NSArray<NSDictionary *> *)dataValues forNodeID:(NSNumber *)nodeID;
- (void)clearStoredAttributesForNodeID:(NSNumber *)nodeID;
- (void)clearAllStoredAttributes;
- (void)_pruneEmptyStoredAttributesBranches;
- (void)unitTestPruneEmptyStoredAttributesBranches;
- (NSString *)_endpointIndexKeyForNodeID:(NSNumber *)nodeID;
- (NSString *)_clusterIndexKeyForNodeID:(NSNumber *)nodeID endpointID:(NSNumber *)endpointID;
- (NSString *)_attributeIndexKeyForNodeID:(NSNumber *)nodeID endpointID:(NSNumber *)endpointID clusterID:(NSNumber *)clusterID;
Expand Down

0 comments on commit 0ddd4ac

Please sign in to comment.