Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #109 from duck8823/fix/stable_test
Browse files Browse the repository at this point in the history
Fix unstable test
  • Loading branch information
duck8823 authored Sep 24, 2018
2 parents 6e4f47c + 207cf45 commit 68227a8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions application/service/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"github.com/duck8823/duci/application/context"
"github.com/duck8823/duci/application/service/git"
"github.com/google/uuid"
"github.com/labstack/gommon/random"
"gopkg.in/src-d/go-git.v4/plumbing"
"net/url"
"os"
"path"
"testing"
"time"
)

func TestNew(t *testing.T) {
Expand Down Expand Up @@ -46,7 +46,8 @@ func TestSshGitService_Clone(t *testing.T) {

t.Run("when target directory exists", func(t *testing.T) {
// setup
tempDir := path.Join(os.TempDir(), fmt.Sprintf("duci_test_%v", time.Now().Unix()))
dirStr := fmt.Sprintf("duci_test_%s", random.String(16, random.Alphanumeric))
tempDir := path.Join(os.TempDir(), dirStr)
if err := os.MkdirAll(path.Join(tempDir, "dir"), 0700); err != nil {
t.Fatalf("%+v", err)
}
Expand Down Expand Up @@ -99,7 +100,8 @@ func TestSshGitService_Clone(t *testing.T) {

t.Run("with wrong sha", func(t *testing.T) {
// setup
tempDir := path.Join(os.TempDir(), fmt.Sprintf("duci_test_%v", time.Now().Unix()))
dirStr := fmt.Sprintf("duci_test_%s", random.String(16, random.Alphanumeric))
tempDir := path.Join(os.TempDir(), dirStr)
if err := os.MkdirAll(path.Join(tempDir, "dir"), 0700); err != nil {
t.Fatalf("%+v", err)
}
Expand Down Expand Up @@ -136,7 +138,8 @@ func TestHttpGitService_Clone(t *testing.T) {

t.Run("when target directory exists", func(t *testing.T) {
// setup
tempDir := path.Join(os.TempDir(), fmt.Sprintf("duci_test_%v", time.Now().Unix()))
dirStr := fmt.Sprintf("duci_test_%s", random.String(16, random.Alphanumeric))
tempDir := path.Join(os.TempDir(), dirStr)
if err := os.MkdirAll(path.Join(tempDir, "dir"), 0700); err != nil {
t.Fatalf("%+v", err)
}
Expand Down Expand Up @@ -189,7 +192,8 @@ func TestHttpGitService_Clone(t *testing.T) {

t.Run("with wrong sha", func(t *testing.T) {
// setup
tempDir := path.Join(os.TempDir(), fmt.Sprintf("duci_test_%v", time.Now().Unix()))
dirStr := fmt.Sprintf("duci_test_%s", random.String(16, random.Alphanumeric))
tempDir := path.Join(os.TempDir(), dirStr)
if err := os.MkdirAll(path.Join(tempDir, "dir"), 0700); err != nil {
t.Fatalf("%+v", err)
}
Expand Down

0 comments on commit 68227a8

Please sign in to comment.