Skip to content
Snippets Groups Projects
Commit e0eecc78 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Merge branch 'hotfix/awaitRemoteStore' into 'hotfix/regstatusSync'

Simple smoke test for ReadDir with the wrapper

See merge request !640
parents 208b03e9 a1bc8998
No related branches found
No related tags found
3 merge requests!640Simple smoke test for ReadDir with the wrapper,!637Add Sync for Registration Status,!617Project/haven beta
...@@ -12,7 +12,11 @@ import ( ...@@ -12,7 +12,11 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"math/rand" "math/rand"
"sync"
"testing" "testing"
"github.com/stretchr/testify/require"
"gitlab.com/xx_network/primitives/netTime"
) )
const ( const (
...@@ -196,32 +200,52 @@ func TestGetChannelInfo(t *testing.T) { ...@@ -196,32 +200,52 @@ func TestGetChannelInfo(t *testing.T) {
// return txLog // return txLog
// } // }
// type mockRemote struct { type mockRemote struct {
// lck sync.Mutex lck sync.Mutex
// data map[string][]byte data map[string][]byte
// } t *testing.T
}
// func (m *mockRemote) Read(path string) ([]byte, error) { func (m *mockRemote) Read(path string) ([]byte, error) {
// m.lck.Lock() m.lck.Lock()
// defer m.lck.Unlock() defer m.lck.Unlock()
// return m.data[path], nil return m.data[path], nil
// } }
// func (m *mockRemote) Write(path string, data []byte) error { func (m *mockRemote) Write(path string, data []byte) error {
// m.lck.Lock() m.lck.Lock()
// defer m.lck.Unlock() defer m.lck.Unlock()
// m.data[path] = append(m.data[path], data...) m.data[path] = append(m.data[path], data...)
// return nil return nil
// } }
// func (m *mockRemote) ReadDir(path string) ([]string, error) { func (m *mockRemote) ReadDir(path string) ([]byte, error) {
// panic("unimplemented") dirs := []string{
// } "hello",
"these",
"are",
"directory",
"names",
}
// func (m mockRemote) GetLastModified(path string) (time.Time, error) { data, err := json.Marshal(dirs)
// return netTime.Now(), nil m.t.Logf("Data: %s", data)
// } return data, err
}
// func (m mockRemote) GetLastWrite() (time.Time, error) { func (m *mockRemote) GetLastModified(path string) ([]byte, error) {
// return netTime.Now(), nil return netTime.Now().MarshalBinary()
// } }
func (m *mockRemote) GetLastWrite() ([]byte, error) {
return netTime.Now().MarshalBinary()
}
func TestReadDir(t *testing.T) {
mRemote := newRemoteStoreFileSystemWrapper(
&mockRemote{t: t, data: make(map[string][]byte)})
dirs, err := mRemote.ReadDir("test")
require.NoError(t, err)
t.Logf("%+v", dirs)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment