mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	Refactor: Exclude modules from json test data when empty (#8533)
* refactor: Exclude modules from json test data when empty * applied murrants patch
This commit is contained in:
		
				
					committed by
					
						
						Tony Murray
					
				
			
			
				
	
			
			
			
						parent
						
							2ee4ea2abc
						
					
				
				
					commit
					fbbc2570c6
				
			@@ -578,6 +578,10 @@ class ModuleTestHelper
 | 
			
		||||
 | 
			
		||||
            // insert new data, don't store duplicate data
 | 
			
		||||
            foreach ($data as $module => $module_data) {
 | 
			
		||||
                // skip saving modules with no data
 | 
			
		||||
                if ($this->dataIsEmpty($module_data['discovery']) && $this->dataIsEmpty($module_data['poller'])) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                if ($module_data['discovery'] == $module_data['poller']) {
 | 
			
		||||
                    $existing_data[$module] = array(
 | 
			
		||||
                        'discovery' => $module_data['discovery'],
 | 
			
		||||
@@ -682,7 +686,7 @@ class ModuleTestHelper
 | 
			
		||||
                        return array_diff_key($row, $keys);
 | 
			
		||||
                    }, $rows);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                
 | 
			
		||||
                if (isset($key)) {
 | 
			
		||||
                    $data[$module][$key][$table] = $rows;
 | 
			
		||||
                } else {
 | 
			
		||||
@@ -779,4 +783,15 @@ class ModuleTestHelper
 | 
			
		||||
        }
 | 
			
		||||
        return $this->json_file;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function dataIsEmpty($data)
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($data as $table_data) {
 | 
			
		||||
            if (!empty($table_data)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user