Skip to content

gitserver: stop reading system env vars in tests

Warren Gifford requested to merge jc/failed-tests-on-mac into main

Created by: unknwon

Some tests that are checking commit IDs are consistently failing on my local macOS because I have GPG configured in my ~/.gitconfig. This PR stops reading from system env vars altogether for tests.

Example failure execution of these tests:

→ go test
--- FAIL: TestRepository_BlameFile (1.14s)
    commands_test.go:362: git cmd: hunks != wantHunks

        hunks ==========
        [
          {
            "StartLine": 1,
            "EndLine": 2,
            "StartByte": 0,
            "EndByte": 6,
            "CommitID": "ca46106c726e82468a64d527df8b5a762d88220b",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f"
          },
          {
            "StartLine": 2,
            "EndLine": 3,
            "StartByte": 6,
            "EndByte": 12,
            "CommitID": "06d21bfafbedc6b8790e5f53acd88cdd6278c349",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f"
          },
          {
            "StartLine": 3,
            "EndLine": 4,
            "StartByte": 12,
            "EndByte": 18,
            "CommitID": "fce1b383ca4d68dad910e9c5df3b982187ea5150",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f2"
          }
        ]

        wantHunks ==========
        [
          {
            "StartLine": 1,
            "EndLine": 2,
            "StartByte": 0,
            "EndByte": 6,
            "CommitID": "e6093374dcf5725d8517db0dccbbf69df65dbde0",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f"
          },
          {
            "StartLine": 2,
            "EndLine": 3,
            "StartByte": 6,
            "EndByte": 12,
            "CommitID": "fad406f4fe02c358a09df0d03ec7a36c2c8a20f1",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f"
          },
          {
            "StartLine": 3,
            "EndLine": 4,
            "StartByte": 12,
            "EndByte": 18,
            "CommitID": "311d75a2b414a77f5158a0ed73ec476f5469b286",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f2"
          }
        ]
    commands_test.go:379: git cmd: hunks != wantHunks

        hunks ==========
        [
          {
            "StartLine": 1,
            "EndLine": 2,
            "StartByte": 0,
            "EndByte": 6,
            "CommitID": "ca46106c726e82468a64d527df8b5a762d88220b",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f"
          },
          {
            "StartLine": 2,
            "EndLine": 3,
            "StartByte": 6,
            "EndByte": 12,
            "CommitID": "06d21bfafbedc6b8790e5f53acd88cdd6278c349",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f"
          },
          {
            "StartLine": 3,
            "EndLine": 4,
            "StartByte": 12,
            "EndByte": 18,
            "CommitID": "fce1b383ca4d68dad910e9c5df3b982187ea5150",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f2"
          }
        ]

        wantHunks ==========
        [
          {
            "StartLine": 1,
            "EndLine": 2,
            "StartByte": 0,
            "EndByte": 6,
            "CommitID": "e6093374dcf5725d8517db0dccbbf69df65dbde0",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f"
          },
          {
            "StartLine": 2,
            "EndLine": 3,
            "StartByte": 6,
            "EndByte": 12,
            "CommitID": "fad406f4fe02c358a09df0d03ec7a36c2c8a20f1",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f"
          },
          {
            "StartLine": 3,
            "EndLine": 4,
            "StartByte": 12,
            "EndByte": 18,
            "CommitID": "311d75a2b414a77f5158a0ed73ec476f5469b286",
            "Author": {
              "Name": "a",
              "Email": "[email protected]",
              "Date": "2006-01-02T15:04:05Z"
            },
            "Message": "foo",
            "Filename": "f2"
          }
        ]
--- FAIL: TestRepository_ResolveBranch (0.33s)
    commands_test.go:445: git cmd: got commitID == ae577c0833e4e9e65dfc336edfcda3f2931e0d28, want ea167fe3d76b1e5fd3ed8ca44cbd2fe3897684f8
--- FAIL: TestRepository_ResolveTag (0.19s)
    commands_test.go:510: git cmd: got commitID == ae577c0833e4e9e65dfc336edfcda3f2931e0d28, want ea167fe3d76b1e5fd3ed8ca44cbd2fe3897684f8

Merge request reports

Loading