Skip to content

Commit 4e1e3c4

Browse files
padureanmmeloni
authored andcommitted
test: remove .root-* files created during immugw tests
1 parent a3baf1a commit 4e1e3c4

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

cmd/immuadmin/command/backup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestDumpToFile(t *testing.T) {
5353
os.RemoveAll(clientDir)
5454
}()
5555
clOp := immuclient.DefaultOptions().WithPort(tcpPort).WithDir(clientDir)
56-
ic, err := immuclient.NewImmuClient(&clOp)
56+
ic, err := immuclient.NewImmuClient(clOp)
5757
if err != nil {
5858
t.Errorf("%s", err.Error())
5959
}

pkg/client/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func DefaultOptions() *Options {
5656
}
5757

5858
// WithDir sets program file folder
59-
func (o Options) WithDir(dir string) Options {
59+
func (o *Options) WithDir(dir string) *Options {
6060
o.Dir = dir
6161
return o
6262
}

pkg/gw/safereference_handler_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ import (
3333
"github.com/grpc-ecosystem/grpc-gateway/runtime"
3434
)
3535

36-
func insertSampleSet(immudbTCPPort int) (string, error) {
36+
var safereferenceHandlerTestDir = "./safereference_handler_test"
37+
38+
func insertSampleSet(immudbTCPPort int, clientDir string) (string, error) {
3739
key := base64.StdEncoding.EncodeToString([]byte("Pablo"))
3840
value := base64.StdEncoding.EncodeToString([]byte("Picasso"))
39-
ic, err := immuclient.NewImmuClient(immuclient.DefaultOptions().WithPort(immudbTCPPort))
41+
ic, err := immuclient.NewImmuClient(immuclient.DefaultOptions().
42+
WithPort(immudbTCPPort).WithDir(clientDir))
4043
if err != nil {
4144
return "", fmt.Errorf("unable to instantiate client: %s", err)
4245
}
@@ -81,14 +84,16 @@ func TestSafeReference(t *testing.T) {
8184
s.Stop()
8285
time.Sleep(2 * time.Second) //without the delay the db dir is deleted before all the data has been flushed to disk and results in crash.
8386
os.RemoveAll(op.Dir)
87+
os.RemoveAll(safereferenceHandlerTestDir)
8488
}()
8589

86-
refKey, err := insertSampleSet(tcpPort)
90+
refKey, err := insertSampleSet(tcpPort, safereferenceHandlerTestDir)
8791
if err != nil {
8892
t.Errorf("%s", err)
8993
}
9094

91-
ic, err := immuclient.NewImmuClient(immuclient.DefaultOptions().WithPort(tcpPort))
95+
ic, err := immuclient.NewImmuClient(immuclient.DefaultOptions().
96+
WithPort(tcpPort).WithDir(safereferenceHandlerTestDir))
9297
if err != nil {
9398
t.Errorf("unable to instantiate client: %s", err)
9499
return

pkg/gw/safeset_handler_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import (
3232
"github.com/grpc-ecosystem/grpc-gateway/runtime"
3333
)
3434

35+
var safesetHandlerTestDir = "./safeset_handler_test"
36+
3537
func generateRandomTCPPort() int {
3638
rand.Seed(time.Now().UnixNano())
3739
min := 1024
@@ -54,9 +56,11 @@ func TestSafeset(t *testing.T) {
5456
s.Stop()
5557
time.Sleep(2 * time.Second) //without the delay the db dir is deleted before all the data has been flushed to disk and results in crash.
5658
os.RemoveAll(op.Dir)
59+
os.RemoveAll(safesetHandlerTestDir)
5760
}()
5861

59-
ic, err := immuclient.NewImmuClient(immuclient.DefaultOptions().WithPort(tcpPort))
62+
ic, err := immuclient.NewImmuClient(immuclient.DefaultOptions().
63+
WithPort(tcpPort).WithDir(safesetHandlerTestDir))
6064
if err != nil {
6165
t.Errorf("unable to instantiate client: %s", err)
6266
return

pkg/gw/safezadd_handler_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import (
3131
"github.com/grpc-ecosystem/grpc-gateway/runtime"
3232
)
3333

34+
var safezaddHandlerTestDir = "./safezadd_handler_test"
35+
3436
func TestSafeZAdd(t *testing.T) {
3537
setName := base64.StdEncoding.EncodeToString([]byte("Soprano"))
3638
uknownKey := base64.StdEncoding.EncodeToString([]byte("Marias Callas"))
@@ -46,13 +48,15 @@ func TestSafeZAdd(t *testing.T) {
4648
s.Stop()
4749
time.Sleep(2 * time.Second) //without the delay the db dir is deleted before all the data has been flushed to disk and results in crash.
4850
os.RemoveAll(op.Dir)
51+
os.RemoveAll(safezaddHandlerTestDir)
4952
}()
5053

51-
refkey, err := insertSampleSet(tcpPort)
54+
refkey, err := insertSampleSet(tcpPort, safezaddHandlerTestDir)
5255
if err != nil {
5356
t.Errorf("%s", err)
5457
}
55-
ic, err := immuclient.NewImmuClient(immuclient.DefaultOptions().WithPort(tcpPort))
58+
ic, err := immuclient.NewImmuClient(immuclient.DefaultOptions().
59+
WithPort(tcpPort).WithDir(safezaddHandlerTestDir))
5660

5761
if err != nil {
5862
t.Errorf("unable to instantiate client: %s", err)

0 commit comments

Comments
 (0)