HostSyncTest: Improve test data to clarify

This commit is contained in:
Markus Frosch 2017-08-30 13:59:45 +02:00 committed by Thomas Gelf
parent 4ab59ea1e3
commit 168369e738

View File

@ -24,14 +24,17 @@ class HostSyncTest extends SyncTest
$this->setUpProperty(array( $this->setUpProperty(array(
'source_expression' => '${host}', 'source_expression' => '${host}',
'destination_field' => 'object_name', 'destination_field' => 'object_name',
'priority' => 10,
)); ));
$this->setUpProperty(array( $this->setUpProperty(array(
'source_expression' => '${address}', 'source_expression' => '${address}',
'destination_field' => 'address', 'destination_field' => 'address',
'priority' => 11,
)); ));
$this->setUpProperty(array( $this->setUpProperty(array(
'source_expression' => '${os}', 'source_expression' => '${os}',
'destination_field' => 'vars.os', 'destination_field' => 'vars.os',
'priority' => 12,
)); ));
$this->assertTrue($this->sync->hasModifications(), 'Should have modifications pending'); $this->assertTrue($this->sync->hasModifications(), 'Should have modifications pending');
@ -46,6 +49,7 @@ class HostSyncTest extends SyncTest
$this->setUpProperty(array( $this->setUpProperty(array(
'source_expression' => '${host}', 'source_expression' => '${host}',
'destination_field' => 'object_name', 'destination_field' => 'object_name',
'priority' => 10,
)); ));
$this->assertFalse($this->sync->hasModifications(), 'Should not have modifications pending'); $this->assertFalse($this->sync->hasModifications(), 'Should not have modifications pending');
@ -57,43 +61,50 @@ class HostSyncTest extends SyncTest
array( array(
'host' => 'SYNCTEST_filtered_in', 'host' => 'SYNCTEST_filtered_in',
'address' => '127.0.0.1', 'address' => '127.0.0.1',
'os' => 'Linux' 'os' => 'Linux',
'sync' => 'yes'
), ),
array( array(
'host' => 'SYNCTEST_filtered_out', 'host' => 'SYNCTEST_filtered_out',
'address' => '127.0.0.1', 'address' => '127.0.0.1',
'os' => null 'os' => null,
'sync' => 'no'
), ),
array( array(
'host' => 'SYNCTEST_filtered_in_unusedfield', 'host' => 'SYNCTEST_filtered_in_unusedfield',
'address' => '127.0.0.1', 'address' => '127.0.0.1',
'os' => null, 'os' => null,
'other' => '1' 'sync' => 'no',
'othersync' => '1'
), ),
array( array(
'host' => 'SYNCTEST_filtered_in_unusedfield_propfilter', 'host' => 'SYNCTEST_filtered_in_unusedfield_propfilter',
'address' => '127.0.0.1', 'address' => '127.0.0.1',
'os' => null, 'os' => null,
'other' => '1', 'magic' => '2',
'magic' => '2', 'sync' => 'no',
'othersync' => '1'
) )
)); ));
$this->rule->set('filter_expression', 'other!=|os=Linux'); $this->rule->set('filter_expression', 'sync=yes|othersync=1');
$this->rule->store(); $this->rule->store();
$this->setUpProperty(array( $this->setUpProperty(array(
'source_expression' => '${host}', 'source_expression' => '${host}',
'destination_field' => 'object_name', 'destination_field' => 'object_name',
'priority' => 10,
)); ));
$this->setUpProperty(array( $this->setUpProperty(array(
'source_expression' => '${address}', 'source_expression' => '${address}',
'destination_field' => 'address', 'destination_field' => 'address',
'priority' => 11,
)); ));
$this->setUpProperty(array( $this->setUpProperty(array(
'source_expression' => 'test-${other}', 'source_expression' => 'test',
'destination_field' => 'vars.other', 'destination_field' => 'vars.magic',
'filter_expression' => 'magic!=' 'filter_expression' => 'magic!=',
'priority' => 12,
)); ));
$modifications = array(); $modifications = array();
@ -111,12 +122,12 @@ class HostSyncTest extends SyncTest
if ($name === 'SYNCTEST_filtered_in_unusedfield_propfilter') { if ($name === 'SYNCTEST_filtered_in_unusedfield_propfilter') {
$this->assertEquals( $this->assertEquals(
'test-1', 'test',
$mod->get('vars.other'), $mod->get('vars.magic'),
$name . ': vars.other should not be synced' $name . ': vars.magic should not be synced'
); );
} else { } else {
$this->assertNull($mod->get('vars.other'), $name . ': vars.other should not be synced'); $this->assertNull($mod->get('vars.magic'), $name . ': vars.magic should not be synced');
} }
} }