Skip to content

Commit

Permalink
Adding error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
vibhansa-msft committed Feb 6, 2024
1 parent 6f5e736 commit 7b5f16d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/e2e_tests/dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,22 +436,37 @@ func (suite *dirTestSuite) TestGitStash() {

cmd := exec.Command("git", "clone", "https://github.com/wastore/azure-storage-samples-for-net", dirName)
_, err := cmd.Output()
if err != nil {
fmt.Printf("Error in git clone : %v\n", err)
}
suite.Equal(nil, err)

_, err = os.Stat(dirName)
if err != nil {
fmt.Printf("Error in stat : %v\n", err)
}
suite.Equal(nil, err)

err = os.Chdir(dirName)
if err != nil {
fmt.Printf("Error in chdir : %v\n", err)
}
suite.Equal(nil, err)

cmd = exec.Command("git", "status")
cliOut, err := cmd.Output()
if err != nil {
fmt.Printf("Error in git status : %v\n", err)
}
suite.Equal(nil, err)
if len(cliOut) > 0 {
suite.Contains(string(cliOut), "nothing to commit, working")
}

f, err := os.OpenFile("README.md", os.O_WRONLY, 0644)
if err != nil {
fmt.Printf("Error in openFile : %v\n", err)
}
suite.Equal(nil, err)
suite.NotZero(f)
info, err := f.Stat()
Expand All @@ -461,6 +476,9 @@ func (suite *dirTestSuite) TestGitStash() {
_ = f.Close()

f, err = os.OpenFile("README.md", os.O_RDONLY, 0644)
if err != nil {
fmt.Printf("Error in openFile2 : %v\n", err)
}
suite.Equal(nil, err)
suite.NotZero(f)
new_info, err := f.Stat()
Expand All @@ -474,24 +492,36 @@ func (suite *dirTestSuite) TestGitStash() {

cmd = exec.Command("git", "status")
cliOut, err = cmd.Output()
if err != nil {
fmt.Printf("Error in git status 2 : %v\n", err)
}
suite.Equal(nil, err)
if len(cliOut) > 0 {
suite.Contains(string(cliOut), "Changes not staged for commit")
}

cmd = exec.Command("git", "stash")
cliOut, err = cmd.Output()
if err != nil {
fmt.Printf("Error in git stash : %v\n", err)
}
suite.Equal(nil, err)
if len(cliOut) > 0 {
suite.Contains(string(cliOut), "Saved working directory and index state WIP")
}

cmd = exec.Command("git", "stash", "list")
_, err = cmd.Output()
if err != nil {
fmt.Printf("Error in git stash list : %v\n", err)
}
suite.Equal(nil, err)

cmd = exec.Command("git", "stash", "pop")
cliOut, err = cmd.Output()
if err != nil {
fmt.Printf("Error in git stash pop : %v\n", err)
}
suite.Equal(nil, err)
if len(cliOut) > 0 {
suite.Contains(string(cliOut), "Changes not staged for commit")
Expand Down

0 comments on commit 7b5f16d

Please sign in to comment.