Add unit tests for git repository functions

Review Request #7053 — Created March 12, 2015 and submitted

Information

rb-gateway
master
bb00723...

Reviewers

Currently rb-gateway has no automated tests. This adds automated tests that checks against all functions in git_repository.go.

Made sure that all tests pass when running go test.

Description From Last Updated

If this is going to be a useful testing utility, maybe this should go in a seperate (testing.utils ?) package.

brenniebrennie

If I run the tests on my mac, I get this: --- FAIL: TestGetPath (0.01s) git_repository_test.go:126: Expected '/var/folders/lp/dyp18_2s6bj05n25pm0k0_880000gn/T/rb-gateway574450298/', got '/private/var/folders/lp/dyp18_2s6bj05n25pm0k0_880000gn/T/rb-gateway574450298/' …

daviddavid

All fake e-mail addresses should use "example.com" (which is reserved for tests and examples), rather than pointing to a real …

daviddavid
reviewbot
  1. Tool: PEP8 Style Checker
    Ignored Files:
        git_repository_test.go
        README.md
    
    
    
    Tool: Pyflakes
    Ignored Files:
        git_repository_test.go
        README.md
    
    
  2. 
      
JY
brennie
  1. 
      
  2. git_repository_test.go (Diff revision 1)
     
     
    Show all issues

    If this is going to be a useful testing utility, maybe this should go in a seperate (testing.utils ?) package.

    1. I put this in main_test.go. I'm still not 100% certain with the way Go organizes tests/code but it seems the trend is to have all test files correspond to a source .go file. git2go puts their utility test functions in their index_test.go file, so I think it makes sense to have rb-gateway use main_test.go. Hopefully I'm doing this right...

  3. 
      
JY
reviewbot
  1. Tool: Pyflakes
    Ignored Files:
        git_repository_test.go
        main_test.go
        README.md
    
    
    
    Tool: PEP8 Style Checker
    Ignored Files:
        git_repository_test.go
        main_test.go
        README.md
    
    
  2. 
      
david
  1. 
      
  2. git_repository_test.go (Diff revision 2)
     
     
    Show all issues

    If I run the tests on my mac, I get this:

    --- FAIL: TestGetPath (0.01s)
        git_repository_test.go:126: Expected '/var/folders/lp/dyp18_2s6bj05n25pm0k0_880000gn/T/rb-gateway574450298/', got '/private/var/folders/lp/dyp18_2s6bj05n25pm0k0_880000gn/T/rb-gateway574450298/'
    

    Which I think is happening because /var is a symbolic link to /private/var. Can you add a call to filepath.EvalSymlinks on the result of TempDir?

    1. I made the change, can you verify that it works in your env? Thanks!

    2. Looks good!

      $ go test -v
      === RUN TestGetName
      --- PASS: TestGetName (0.01s)
      === RUN TestGetPath
      --- PASS: TestGetPath (0.00s)
      === RUN TestGetFile
      --- PASS: TestGetFile (0.01s)
      === RUN TestGetFileByCommit
      --- PASS: TestGetFileByCommit (0.01s)
      === RUN TestFileExists
      --- PASS: TestFileExists (0.01s)
      === RUN TestFileExistsByCommit
      --- PASS: TestFileExistsByCommit (0.01s)
      === RUN TestGetBranches
      --- PASS: TestGetBranches (0.02s)
      === RUN TestGetCommits
      --- PASS: TestGetCommits (0.02s)
      === RUN TestGetCommit
      --- PASS: TestGetCommit (0.01s)
      PASS
      ok      _/Users/david/Projects/rb-gateway   0.172s
      
  3. git_repository_test.go (Diff revision 2)
     
     
    Show all issues

    All fake e-mail addresses should use "example.com" (which is reserved for tests and examples), rather than pointing to a real website.

  4. 
      
JY
reviewbot
  1. Tool: PEP8 Style Checker
    Ignored Files:
        git_repository_test.go
        main_test.go
        README.md
    
    
    
    Tool: Pyflakes
    Ignored Files:
        git_repository_test.go
        main_test.go
        README.md
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
JY
Review request changed
Status:
Completed
Change Summary:
Pushed to master (27f86a8)