Esempio n. 1
0
func TestClearFriendsData(t *testing.T) {
	var err error
	storage.New("internal")
	data := []byte{}
	storage.StoreLocalData(data, enum.SHARED)
	storage.StoreClusterData(data, enum.SHARED)
	storage.StoreData("node1", data, enum.SHARED)
	storage.StoreData("node2", data, enum.SHARED)
	storage.StoreData("node3", data, enum.SHARED)

	err = clearFriendsData()
	assert.NoError(t, err)
	stored, _ := storage.GetAllData(enum.SHARED)
	assert.Equal(t, 2, len(stored))
}
Esempio n. 2
0
func clearFriendsData() error {
	allData, err := storage.GetAllData(enum.SHARED)
	if err != nil {
		log.Errorln("Error cleaning up friends data")
		return err
	}

	for key, _ := range allData {
		if key != enum.CLUSTER.ToString() && key != enum.LOCAL.ToString() {
			log.WithField("friend", key).Debugln("cleared friend data")
			storage.DeleteData(key, enum.SHARED)
		}
	}

	return nil
}