2021-05-24 05:27:07 +00:00
|
|
|
package git
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
2021-06-15 21:11:35 +00:00
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/ioutils"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2021-05-24 05:27:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestService_ClonePrivateRepository_GitHub(t *testing.T) {
|
|
|
|
ensureIntegrationTest(t)
|
|
|
|
|
|
|
|
pat := getRequiredValue(t, "GITHUB_PAT")
|
|
|
|
username := getRequiredValue(t, "GITHUB_USERNAME")
|
|
|
|
service := NewService()
|
|
|
|
|
|
|
|
dst, err := ioutils.TempDir("", "clone")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
defer os.RemoveAll(dst)
|
|
|
|
|
|
|
|
repositoryUrl := "https://github.com/portainer/private-test-repository.git"
|
2021-06-15 21:11:35 +00:00
|
|
|
err = service.CloneRepository(dst, repositoryUrl, "refs/heads/main", username, pat)
|
2021-05-24 05:27:07 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.FileExists(t, filepath.Join(dst, "README.md"))
|
|
|
|
}
|