Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Commit

Permalink
Update some job-related tests for Splunk 5.0b.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfstr committed Sep 17, 2012
1 parent af1c5f9 commit 5bf69d0
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions tests/JobTest.php
Expand Up @@ -146,21 +146,52 @@ public function testValidResultsForNormalJob()
'No rows were reported in the job results.');
}

/**
* @expectedException Splunk_JobNotDoneException
*/
public function testResultsNotDone()
{
$service = $this->loginToRealService();

// (This search is installed by default on Splunk 4.x.)
$ss = $service->getSavedSearches()->get('Top five sourcetypes');
$job = $ss->dispatch();
$job = $service->getJobs()->create('search index=_internal');

$this->assertFalse($job->isDone(),
'Job completed too fast. Please rewrite this unit test to avoid timing issues.');

$job->getResultsPage();
try
{
$job->getResultsPage();

$job->delete();
$this->fail('Expected Splunk_JobNotDoneException.');
}
catch (Splunk_JobNotDoneException $e)
{
// Good
$job->delete();
}
}

public function testResultsEmpty()
{
$SEARCHES = array(
'search index=_internal x NOT x',
'search index=_does_not_exist',
);

$service = $this->loginToRealService();

foreach ($SEARCHES as $search)
{
$job = $service->getJobs()->create('search index=_internal x NOT x', array(
'exec_mode' => 'blocking'
));

$results = new Splunk_ResultsReader($job->getResultsPage());
$hasResults = FALSE;
foreach ($results as $result)
{
$hasResults = TRUE;
}
$this->assertFalse($hasResults);
}
}

public function testResultsPageInNamespace()
Expand Down

0 comments on commit 5bf69d0

Please sign in to comment.