agentzh/test-nginx — pull request #2 by bigplum (2012-02-23 02:07:38+00:00)
Title: support checking specified file content

=head2 cache_file

Checks if content of the file is equal to specified string. First section seperated by colon is file name and the second section is match string.

--- cache_file
/tmp/cache_file: abcd

For example,

=== TEST 1: write to file
--- config
location /write/to/file {
content_by_lua '
io.output("/tmp/cache_file",rw);
io.write("abcd");
io.flush();
io.close();
';
}
--- request
GET /write/to/file
--- error_code: 200
--- cache_file
/tmp/cache_file: abcd
/tmp/cache_file: abc

Then content of the F is "abcd", first case should be passed and second case failed.

=head2 cache_file_like

Checks if specified pattern matches one line of the file. First section seperated by colon is file name and the second section is match pattern.

For example,

=== TEST 1: write to file
--- config
location /write/to/file {
content_by_lua '
io.output("/tmp/cache_file",rw);
io.write("abcd");
io.flush();
io.close();
';
}
--- request
GET /write/to/file
--- error_code: 200
--- cache_file_like
/tmp/cache_file: abcde
/tmp/cache_file: ^abc

Then content of the F is "abcd", first case should be failed and second case passed.