mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
parent
a55d257be1
commit
2d5b34cfc2
2 changed files with 40 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -169,6 +170,37 @@ func TestGitFindRef(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGitCloneExecutor(t *testing.T) {
|
||||
for name, tt := range map[string]struct {
|
||||
URL string
|
||||
Ref string
|
||||
Err error
|
||||
}{
|
||||
"tag": {
|
||||
URL: "https://github.com/actions/checkout",
|
||||
Ref: "v2",
|
||||
Err: nil,
|
||||
},
|
||||
"branch": {
|
||||
URL: "https://github.com/anchore/scan-action",
|
||||
Ref: "act-fails",
|
||||
Err: nil,
|
||||
},
|
||||
} {
|
||||
tt := tt
|
||||
name := name
|
||||
t.Run(name, func(t *testing.T) {
|
||||
clone := NewGitCloneExecutor(NewGitCloneExecutorInput{
|
||||
URL: tt.URL,
|
||||
Ref: tt.Ref,
|
||||
Dir: testDir(t),
|
||||
})
|
||||
err := clone(context.Background())
|
||||
assert.ErrorIs(t, err, tt.Err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func gitConfig() {
|
||||
if os.Getenv("GITHUB_ACTIONS") == "true" {
|
||||
_ = gitCmd("config", "--global", "user.email", "test@test.com")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue