Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: working dir tests initial branch assumes "master" #2264

Merged
merged 1 commit into from
May 17, 2022

Conversation

ascandella
Copy link
Contributor

@ascandella ascandella commented May 17, 2022

This fixes the tests to not rely in the implicit value of the
"defaultBranch" git configuration value, since they later assume that
it's "master".

For example, if you run:

git config --global init.defaultBranch main

And then run these tests, you get:

--- FAIL: TestClone_CheckoutMergeNoneExisting (0.69s)
    working_dir_test.go:71: err running "git checkout master": error: pathspec 'master' did not match any file(s) known to git
        
--- FAIL: TestClone_CheckoutMergeNoReclone (0.71s)
    working_dir_test.go:127: err running "git checkout master": error: pathspec 'master' did not match any file(s) known to git
        
--- FAIL: TestClone_CheckoutMergeNoRecloneFastForward (0.71s)
    logger.go:130: 2022-05-17T10:15:03.244-0700 INFO    creating dir "/tmp/3840955393/repos/0/default"
    working_dir_test.go:198: unexpected error: running git clone --branch master --single-branch file:///tmp/857183047 /tmp/3840955393/repos/0/default: Cloning into '/tmp/3840955393/repos/0/default'...
        warning: Could not find remote branch master to clone.
        fatal: Remote branch master not found in upstream origin
        : exit status 128
--- FAIL: TestClone_CheckoutMergeConflict (0.69s)
    working_dir_test.go:232: err running "git checkout master": error: pathspec 'master' did not match any file(s) known to git
        
--- FAIL: TestClone_MasterHasDiverged (0.68s)
    working_dir_test.go:344: err running "git clone --branch master --single-branch /tmp/3624040418 .": Cloning into '.'...
        warning: Could not find remote branch master to clone.
        fatal: Remote branch master not found in upstream origin
        
--- FAIL: TestHasDiverged_MasterHasDiverged (0.68s)
    working_dir_test.go:415: err running "git clone --branch master --single-branch /tmp/3534950134 .": Cloning into '.'...
        warning: Could not find remote branch master to clone.
        fatal: Remote branch master not found in upstream origin
        
FAIL
FAIL    github.com/runatlantis/atlantis/server/events   8.831s

This fixes the tests to not rely in the implicit value of the
"defaultBranch" git configuration value, since they later assume that
it's "master".

For example, if you run:

```sh
git config --global init.defaultBranch main
```

And then run these tests, you get:

```sh
--- FAIL: TestClone_CheckoutMergeNoneExisting (0.68s)
    working_dir_test.go:71: err running "git checkout master": error:
    pathspec 'master' did not match any file(s) known to git

    --- FAIL: TestClone_CheckoutMergeNoReclone (0.68s)
        working_dir_test.go:127: err running "git checkout master":
        error: pathspec 'master' did not match any file(s) known to git

        --- FAIL: TestClone_CheckoutMergeNoRecloneFastForward (0.68s)
            logger.go:130: 2022-05-17T10:05:33.665-0700 INFO    creating
            dir "/tmp/3762936464/repos/0/default"
                working_dir_test.go:198: unexpected error: running git
                clone --branch master --single-branch
                file:///tmp/3657236513 /tmp/3762936464/repos/0/default:
                Cloning into '/tmp/3762936464/repos/0/default'...
                        warning: Could not find remote branch master to
                        clone.
                                fatal: Remote branch master not found in
                                upstream origin
                                        : exit status 128
                                        --- FAIL:
                                        TestClone_CheckoutMergeConflict
                                        (0.68s)
      working_dir_test.go:232: err running "git checkout master": error:
      pathspec 'master' did not match any file(s) known to git

      --- FAIL: TestClone_MasterHasDiverged (0.68s)
          working_dir_test.go:344: err running "git clone --branch
          master --single-branch /tmp/1931262087 .": Cloning into '.'...
                  warning: Could not find remote branch master to clone.
                          fatal: Remote branch master not found in
                          upstream origin

                          --- FAIL: TestHasDiverged_MasterHasDiverged
(0.68s)
      working_dir_test.go:415: err running "git clone --branch master
      --single-branch /tmp/2356723317 .": Cloning into '.'...
              warning: Could not find remote branch master to clone.
                      fatal: Remote branch master not found in upstream
                      origin

                      FAIL
                      FAIL
                      github.com/runatlantis/atlantis/server/events
                      7.269s
                      FAIL
```
@ascandella ascandella requested a review from a team as a code owner May 17, 2022 17:08
Copy link
Contributor

@jamengual jamengual left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jamengual jamengual merged commit 8bc3c08 into runatlantis:master May 17, 2022
@ascandella ascandella deleted the fix-tests-main branch May 17, 2022 17:55
krrrr38 pushed a commit to krrrr38/atlantis that referenced this pull request Dec 16, 2022
)

This fixes the tests to not rely in the implicit value of the
"defaultBranch" git configuration value, since they later assume that
it's "master".

For example, if you run:

```sh
git config --global init.defaultBranch main
```

And then run these tests, you get:

```sh
--- FAIL: TestClone_CheckoutMergeNoneExisting (0.68s)
    working_dir_test.go:71: err running "git checkout master": error:
    pathspec 'master' did not match any file(s) known to git

    --- FAIL: TestClone_CheckoutMergeNoReclone (0.68s)
        working_dir_test.go:127: err running "git checkout master":
        error: pathspec 'master' did not match any file(s) known to git

        --- FAIL: TestClone_CheckoutMergeNoRecloneFastForward (0.68s)
            logger.go:130: 2022-05-17T10:05:33.665-0700 INFO    creating
            dir "/tmp/3762936464/repos/0/default"
                working_dir_test.go:198: unexpected error: running git
                clone --branch master --single-branch
                file:///tmp/3657236513 /tmp/3762936464/repos/0/default:
                Cloning into '/tmp/3762936464/repos/0/default'...
                        warning: Could not find remote branch master to
                        clone.
                                fatal: Remote branch master not found in
                                upstream origin
                                        : exit status 128
                                        --- FAIL:
                                        TestClone_CheckoutMergeConflict
                                        (0.68s)
      working_dir_test.go:232: err running "git checkout master": error:
      pathspec 'master' did not match any file(s) known to git

      --- FAIL: TestClone_MasterHasDiverged (0.68s)
          working_dir_test.go:344: err running "git clone --branch
          master --single-branch /tmp/1931262087 .": Cloning into '.'...
                  warning: Could not find remote branch master to clone.
                          fatal: Remote branch master not found in
                          upstream origin

                          --- FAIL: TestHasDiverged_MasterHasDiverged
(0.68s)
      working_dir_test.go:415: err running "git clone --branch master
      --single-branch /tmp/2356723317 .": Cloning into '.'...
              warning: Could not find remote branch master to clone.
                      fatal: Remote branch master not found in upstream
                      origin

                      FAIL
                      FAIL
                      github.com/runatlantis/atlantis/server/events
                      7.269s
                      FAIL
```
@nitrocode nitrocode added this to the v0.19.4 milestone Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants