Skip to content

Commit

Permalink
update: fix unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
hyponet committed Apr 4, 2024
1 parent 104ea84 commit c74e475
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
16 changes: 12 additions & 4 deletions cmd/apps/apis/fsapi/v1/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/test/bufconn"
"net"
"os"
"testing"
)

Expand Down Expand Up @@ -64,7 +65,10 @@ var _ = BeforeSuite(func() {
Expect(err).Should(BeNil())
testMeta = memMeta

storage.InitLocalCache(config.Config{CacheDir: "/tmp", CacheSize: 0})
workdir, err := os.MkdirTemp(os.TempDir(), "ut-nanafs-fsapi-")
Expect(err).Should(BeNil())

storage.InitLocalCache(config.Config{CacheDir: workdir, CacheSize: 0})

ctrl, err = controller.New(mockConfig{}, memMeta)
Expect(err).Should(BeNil())
Expand Down Expand Up @@ -106,9 +110,13 @@ var _ = BeforeSuite(func() {
})

var _ = AfterSuite(func() {
err := mockListen.Close()
Expect(err).Should(BeNil())
testServer.Stop()
if mockListen != nil {
err := mockListen.Close()
Expect(err).Should(BeNil())
}
if testServer != nil {
testServer.Stop()
}
})

type Client struct {
Expand Down
10 changes: 9 additions & 1 deletion cmd/apps/fs/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,15 @@ var _ = Describe("TestRmdir", func() {
Describe("can not see old dir", func() {
ds, err := root.Readdir(context.Background())
Expect(err).To(Equal(syscall.Errno(0)))
Expect(ds.HasNext()).To(BeFalse())
found := false
for ds.HasNext() {
ch, err := ds.Next()
Expect(err).To(Equal(syscall.Errno(0)))
if ch.Name == dirName {
found = true
}
}
Expect(found).To(BeFalse())
ds.Close()
})
})
Expand Down

0 comments on commit c74e475

Please sign in to comment.