basho/webmachine — pull request #109 by kellymclaughlin (2013-01-04 06:29:04+00:00)
Title: Repair and refactoring of the etag eqc test

Change the `etag_prop` property to use `"*"` as the value for the `If` header if the list of values generated for that header is empty. This simultaneously corrects a bad expectation by the property and expands the scope of the test.

This test checks the behavior of the `If-Match` and `If-None-Match` headers. Previously if the list of values to use for the header was empty, the header would be set in the HTTP request with no value which was treated the same as if the header was not present at all. This caused the test to fail because if the `IfVals` list was empty then `CurVal` would never be a member of it and the expected HTTP response code would be the opposite of what was actually received (`204` instead of `412` for `If-Match` and the reverse for `If-None-Match`).

This pull request changes the test behavior so that if the list of generated values for the `If` header is empty, the value for the header is set to `"*"`. This list of generated values is also used to determine the proper expectation for the HTTP response code. For reference on the meaning of `"*"` as the value for `If-Match` and `If-None-Match` headers here is some relevant text from [rfc2616, sec 14](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html):

>The meaning of "If-Match: *" is that the method SHOULD be performed if the representation selected >by the origin server (or by a cache, possibly using the Vary mechanism, see section 14.44) exists, and >MUST NOT be performed if the representation does not exist.

>The meaning of "If-None-Match: *" is that the method MUST NOT be performed if the representation >selected by the origin server (or by a cache, possibly using the Vary mechanism, see section 14.44) >exists, and SHOULD be performed if the representation does not exist.

Also, the eunit setup has been refactored to use a test suite and use the `eqc:testing_time` function to execute for 10 seconds as opposed to a fixed 250 iterations.