tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_get_commits.py (1259B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 import mozunit
      6 
      7 from mozversioncontrol import get_repository_object
      8 
      9 STEPS = {
     10    "hg": [
     11        """
     12        echo bar >> bar
     13        hg commit -m "commit 1"
     14        echo baz > baz
     15        hg add baz
     16        hg commit -m "commit 2"
     17        """
     18    ],
     19    "git": [
     20        """
     21        echo bar >> bar
     22        git add bar
     23        git commit -m "commit 1"
     24        echo baz > baz
     25        git add baz
     26        git commit -m "commit 2"
     27        """
     28    ],
     29    "jj": [
     30        # snapshot, since mach's jj integration avoids doing this automatically
     31        """
     32        echo bar >> bar
     33        jj commit -m "commit 1"
     34        echo baz > baz
     35        jj commit -m "commit 2"
     36        jj log -n0
     37        """
     38    ],
     39 }
     40 
     41 
     42 def test_get_commits(repo):
     43    vcs = get_repository_object(repo.dir)
     44 
     45    # Create some commits
     46    repo.execute_next_step()
     47 
     48    # Get list of branch nodes.
     49    nodes = vcs.get_commits()
     50 
     51    assert len(nodes) == 2
     52    assert all(len(node) == 40 for node in nodes), "Each node should be a 40-char SHA."
     53 
     54 
     55 if __name__ == "__main__":
     56    mozunit.main()