diff options
author | Jon Bratseth <bratseth@oath.com> | 2022-02-01 14:49:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-01 14:49:35 +0100 |
commit | c58ca3fc3a6ea6284d6ffcc7807a923a106e3246 (patch) | |
tree | 723d7b47c0ee426dac1f565bff7f3f431962d163 | |
parent | 479caa24f458444169ab4a3a5a50a934bc13f6b0 (diff) | |
parent | 4fe5720783326e759f0f04a9d2a8008cb0f727a2 (diff) |
Merge pull request #21007 from vespa-engine/mpolden/write-tempfile-to-same-path
Write temporary file to same directory as final file
-rw-r--r-- | client/go/cmd/test_test.go | 7 | ||||
-rw-r--r-- | client/go/util/io.go | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/client/go/cmd/test_test.go b/client/go/cmd/test_test.go index 6649353df77..490527df224 100644 --- a/client/go/cmd/test_test.go +++ b/client/go/cmd/test_test.go @@ -5,9 +5,6 @@ package cmd import ( - "fmt" - "github.com/vespa-engine/vespa/client/go/util" - "github.com/vespa-engine/vespa/client/go/vespa" "io/ioutil" "net/http" "net/url" @@ -16,6 +13,9 @@ import ( "strings" "testing" + "github.com/vespa-engine/vespa/client/go/util" + "github.com/vespa-engine/vespa/client/go/vespa" + "github.com/stretchr/testify/assert" ) @@ -40,7 +40,6 @@ func TestSuite(t *testing.T) { requests = append(requests, createSearchRequest(baseUrl+"/search/")) } assertRequests(requests, client, t) - fmt.Println(outBytes) assert.Equal(t, string(expectedBytes), outBytes) assert.Equal(t, "", errBytes) } diff --git a/client/go/util/io.go b/client/go/util/io.go index 23bfec84879..68b50733006 100644 --- a/client/go/util/io.go +++ b/client/go/util/io.go @@ -11,6 +11,7 @@ import ( "io" "io/ioutil" "os" + "path/filepath" "strings" ) @@ -53,7 +54,8 @@ func ReaderToJSON(reader io.Reader) string { // AtomicWriteFile atomically writes data to filename. func AtomicWriteFile(filename string, data []byte) error { - tmpFile, err := ioutil.TempFile("", "vespa") + dir := filepath.Dir(filename) + tmpFile, err := ioutil.TempFile(dir, "vespa") if err != nil { return err } |