13996: Migrate tests to new config
[arvados.git] / services / api / lib / config_loader.rb
index 6bfbdd7a83dea4918c1173c33e168ae84c171082..1a4135e84280345ed7626c76c1981f4568370edd 100644 (file)
@@ -29,7 +29,7 @@ module Psych
 end
 
 def set_cfg cfg, k, v
-  # "foo.bar: baz" --> { config.foo.bar = baz }
+  # "foo.bar = baz" --> { cfg["foo"]["bar"] = baz }
   ks = k.split '.'
   k = ks.pop
   ks.each do |kk|
@@ -126,9 +126,19 @@ def coercion_and_check check_cfg
       end
     end
 
+    if cfgtype == URI
+      cfg[k] = URI(cfg[k])
+    end
+
     if !cfg[k].is_a? cfgtype
       raise "#{cfgkey} expected #{cfgtype} but was #{cfg[k].class}"
     end
   end
 
 end
+
+def copy_into_config src, dst
+  src.each do |k, v|
+    dst.send "#{k}=", Marshal.load(Marshal.dump v)
+  end
+end