Remove an endpoint from the pending assocs

If there is a pending association, but the object that
owns that association goes off the bus, then there is
no need to wait for the endpoint to show up anymore so
remove it from the pending associations list.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I96af6ffd62f857015522c041dfbdbcd2132d8374
diff --git a/src/test/associations.cpp b/src/test/associations.cpp
index cebd614..5f87020 100644
--- a/src/test/associations.cpp
+++ b/src/test/associations.cpp
@@ -415,3 +415,32 @@
     // 1 pending association
     EXPECT_EQ(assocMaps.pending.size(), 1);
 }
+
+// Test removing pending associations
+TEST_F(TestAssociations, testRemoveFromPendingAssociations)
+{
+    AssociationMaps assocMaps;
+
+    addPendingAssociation(DEFAULT_SOURCE_PATH, "inventory", DEFAULT_ENDPOINT,
+                          "error", DEFAULT_DBUS_SVC, assocMaps);
+
+    addPendingAssociation(DEFAULT_SOURCE_PATH, "inventory",
+                          "some/other/endpoint", "error", DEFAULT_DBUS_SVC,
+                          assocMaps);
+
+    EXPECT_EQ(assocMaps.pending.size(), 1);
+
+    removeFromPendingAssociations("some/other/endpoint", assocMaps);
+
+    // Still 1 pending entry, but down to 1 endpoint
+    EXPECT_EQ(assocMaps.pending.size(), 1);
+
+    auto assoc = assocMaps.pending.find(DEFAULT_SOURCE_PATH);
+    EXPECT_NE(assoc, assocMaps.pending.end());
+    auto& endpoints = assoc->second;
+    EXPECT_EQ(endpoints.size(), 1);
+
+    // Now nothing pending
+    removeFromPendingAssociations(DEFAULT_ENDPOINT, assocMaps);
+    EXPECT_EQ(assocMaps.pending.size(), 0);
+}