Bug 1641691 - sort managed resources for cleaner diffs. r=Callek
authorAki Sasaki <asasaki@mozilla.com>
Fri, 29 May 2020 14:03:51 +0000
changeset 233 4a787c62d44e36e901fb463b8686bdb3ea1d5ce0
parent 232 f0753622410594905371d557d85af3c8ac1c672e
child 234 947e18c353cbfb4d3aebc5b5fe5dc9525c288510
push id168
push userasasaki@mozilla.com
push dateFri, 29 May 2020 17:54:46 +0000
treeherderci-admin@4a787c62d44e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCallek
bugs1641691
Bug 1641691 - sort managed resources for cleaner diffs. r=Callek Differential Revision: https://phabricator.services.mozilla.com/D77362
src/tcadmin/resources/resources.py
tests/tcadmin/test_resources_resources.py
--- a/src/tcadmin/resources/resources.py
+++ b/src/tcadmin/resources/resources.py
@@ -151,17 +151,17 @@ class Resources:
         return self.managed.matches(id)
 
     def __iter__(self):
         return self.resources.__iter__()
 
     def __str__(self):
         self._verify()
         return "managed:\n{}\n\nresources:\n{}".format(
-            "\n".join("  - " + m for m in self.managed),
+            "\n".join("  - " + m for m in sorted(self.managed)),
             textwrap.indent("\n\n".join(str(r) for r in self), "  "),
         )
 
     def __repr__(self):
         return pretty_json(self.to_json())
 
     def to_json(self):
         "Convert to a JSON-able data structure"
--- a/tests/tcadmin/test_resources_resources.py
+++ b/tests/tcadmin/test_resources_resources.py
@@ -196,23 +196,23 @@ def test_resources_verify_unmanaged_proh
     "Duplicate resources are not allowed"
     with pytest.raises(RuntimeError, message="unmanaged resources: ListThing=y"):
         Resources([Thing("x", "1"), ListThing("y", [])], ["Thing=*"])._verify()
 
 
 def test_resources_str():
     "Resources are stringified in order"
     resources = Resources(
-        [Thing("x", "1"), Thing("y", "1")], ["Thing=*", "OtherStuff=.*"]
+        [Thing("x", "1"), Thing("y", "1")], ["OtherStuff=.*", "Thing=*",]
     )
     assert str(resources) == textwrap.dedent(
         """\
       managed:
+        - OtherStuff=.*
         - Thing=*
-        - OtherStuff=.*
 
       resources:
         Thing=x:
           thingId: x
           value: 1
 
         Thing=y:
           thingId: y