Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows incompatibility with /tmp #3252

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/integration/operatorhub/cmd_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package integration
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
Expand Down Expand Up @@ -129,7 +130,7 @@ var _ = Describe("odo service command tests for OperatorHub", func() {

// stdOut contains the yaml specification. Store it to a file
randomFileName := helper.RandString(6) + ".yaml"
fileName := filepath.Join("/tmp", randomFileName)
fileName := filepath.Join(os.TempDir(), randomFileName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prietyc123 +1, however i would suggest keep those lines that bring changes to the system in a teardown steps like justBeforeEach and JustAfterEach. Because, consider a case where you created a file within a spec and did certain operation and an immediate oc or odo command fails, then the created file will be left behind for sure. So it's better to have those things in teardown steps, in case the spec command fails the teardown steps will anyway cleanup these files.

I won't mind if you fix this in a separate pr. But for now atleast remove the created file at the end of the spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

however i would suggest keep those lines that bring changes to the system in a teardown steps like justBeforeEach and JustAfterEach.

+1 Good point, its better to accumulate all those such cases in our test suite and fix them in a single shoot, i will take a look and send another in pr as a refactor for sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

if err := ioutil.WriteFile(fileName, []byte(stdOut), 0644); err != nil {
fmt.Printf("Could not write yaml spec to file %s because of the error %v", fileName, err.Error())
}
Expand Down