]> git.openstreetmap.org Git - rails.git/commitdiff
Speed up tests by making fewer random changes
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 6 Jun 2018 05:54:09 +0000 (13:54 +0800)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 6 Jun 2018 05:54:09 +0000 (13:54 +0800)
The old_node_controller#test_version in particular was slow, since
it saves a huge number of tags when adding a tag 30 times over. Since
the tests are random and not based on the number of iterations, this
reduces the iteration counts.

test/controllers/changeset_controller_test.rb
test/controllers/old_node_controller_test.rb

index 38d6ac162ce1e648170b842dfa3ec9e64fe7c79f..e8fde7c92cd73594852716c26733945f5d116b8a 100644 (file)
@@ -557,7 +557,7 @@ CHANGESET
   end
 
   def test_repeated_changeset_create
   end
 
   def test_repeated_changeset_create
-    30.times do
+    3.times do
       basic_authorization create(:user).email, "test"
 
       # create a temporary changeset
       basic_authorization create(:user).email, "test"
 
       # create a temporary changeset
index e08fbb65ec48cc5beb278ac7277d0801d0800b66..1f87431415dff2bd75ef7e46470a3e8091ba9dc3 100644 (file)
@@ -55,7 +55,7 @@ class OldNodeControllerTest < ActionController::TestCase
     versions[xml_node["version"]] = xml_doc.to_s
 
     # randomly move the node about
     versions[xml_node["version"]] = xml_doc.to_s
 
     # randomly move the node about
-    20.times do
+    3.times do
       # move the node somewhere else
       xml_node["lat"] = precision(rand * 180 - 90).to_s
       xml_node["lon"] = precision(rand * 360 - 180).to_s
       # move the node somewhere else
       xml_node["lat"] = precision(rand * 180 - 90).to_s
       xml_node["lon"] = precision(rand * 360 - 180).to_s
@@ -70,7 +70,7 @@ class OldNodeControllerTest < ActionController::TestCase
     end
 
     # add a bunch of random tags
     end
 
     # add a bunch of random tags
-    30.times do
+    3.times do
       xml_tag = XML::Node.new("tag")
       xml_tag["k"] = random_string
       xml_tag["v"] = random_string
       xml_tag = XML::Node.new("tag")
       xml_tag["k"] = random_string
       xml_tag["v"] = random_string
@@ -105,7 +105,7 @@ class OldNodeControllerTest < ActionController::TestCase
     versions[xml_node["version"]] = xml_doc.to_s
 
     # randomly move the node about
     versions[xml_node["version"]] = xml_doc.to_s
 
     # randomly move the node about
-    20.times do
+    3.times do
       # move the node somewhere else
       xml_node["lat"] = precision(rand * 180 - 90).to_s
       xml_node["lon"] = precision(rand * 360 - 180).to_s
       # move the node somewhere else
       xml_node["lat"] = precision(rand * 180 - 90).to_s
       xml_node["lon"] = precision(rand * 360 - 180).to_s
@@ -120,7 +120,7 @@ class OldNodeControllerTest < ActionController::TestCase
     end
 
     # add a bunch of random tags
     end
 
     # add a bunch of random tags
-    30.times do
+    3.times do
       xml_tag = XML::Node.new("tag")
       xml_tag["k"] = random_string
       xml_tag["v"] = random_string
       xml_tag = XML::Node.new("tag")
       xml_tag["k"] = random_string
       xml_tag["v"] = random_string