v2 of google storage unit tests - here I include a monkey patch to address an issue with vcr gem normalisation of HTTP body (as explained in original patch series)...
Patch 1/3 contains fixes for google storage driver that came up when writing the tests$ Patch 2/3 contains the unit tests and vcr recordings. Invoke the tests by 'cd /path/to/deltacloud/server; rake test:google' Patch 3/3 contains the monkey patch for VCR body normalisation original patch series introduction message follows for convenience marios ===================[original patch series introduction]=================== Patch 1/2 contains fixes for google storage driver that came up when writing the tests Patch 2/2 contains the unit tests and vcr recordings. Invoke the tests by 'cd /path/to/deltacloud/server; rake test:google' If you are interested in recording new vcr episodes for google storage, read on: =============================================================================== The mocking for vcr is done with excon; the google-storage driver uses fog to talk to the google-storage service, and fog uses excon for http connections. I came across a couple of issues when trying to make the vcr recordings, as reported here for example https://groups.google.com/group/ruby-fog/browse_thread/thread/737295ebb42e67d1/7e5a09463c4513c2?lnk=gst&q=fog+and+vcr#7e5a09463c4513c2 Another issue is that the vcr code tries to 'normalise' the HTTP body, as described here https://github.com/myronmarston/vcr/issues/4 However, for the 'create blob' test, the body is a tempfile which caused the normalisation to fail (normalisation is done by String.new(body)). Thus, in order to record 'new' episodes for google storage I had to change the normalisation code: The patch is for vcr version 1.11.3 (current @ Rubygems.org)... however for v2.0.0 currently in beta (cloned from github) the noralisation code has been moved to ./lib/vcr/cassette/migrator.rb:105 . I'll report the issue to github. >From 5ad2e93a1c0d38164953b0845b83e141ddd9b494 Mon Sep 17 00:00:00 2001 From: marios <mar...@redhat.com> Date: Wed, 2 Nov 2011 11:17:14 +0200 Subject: [PATCH] Fix normaliser - don't normalise body when body is a tempfile --- lib/vcr/structs/normalizers/body.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/vcr/structs/normalizers/body.rb b/lib/vcr/structs/normalizers/body.rb index 6b013fc..e07ec75 100644 --- a/lib/vcr/structs/normalizers/body.rb +++ b/lib/vcr/structs/normalizers/body.rb @@ -16,7 +16,7 @@ module VCR # http://github.com/myronmarston/vcr/issues/4 self.body = case body when nil, ''; nil - else String.new(body) + else String.new(body) unless body.is_a?(Tempfile) end end end -- 1.7.6.4