mirror of
https://github.com/logos-storage/logos-storage-go-bindings.git
synced 2026-01-07 16:03:06 +00:00
Add cancellation test
This commit is contained in:
parent
43e6e5e81f
commit
fca7f76ac1
@ -45,7 +45,6 @@ func TestUploadReader(t *testing.T) {
|
|||||||
|
|
||||||
func TestUploadReaderCancel(t *testing.T) {
|
func TestUploadReaderCancel(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
codex := newCodexNode(t)
|
codex := newCodexNode(t)
|
||||||
buf := bytes.NewBuffer(make([]byte, 1024*1024*10))
|
buf := bytes.NewBuffer(make([]byte, 1024*1024*10))
|
||||||
@ -107,10 +106,8 @@ func TestUploadFile(t *testing.T) {
|
|||||||
|
|
||||||
func TestUploadFileCancel(t *testing.T) {
|
func TestUploadFileCancel(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
// create a tmp file with large content
|
tmpFile, err := os.Create(os.TempDir() + "/large_file.txt")
|
||||||
tmpFile, err := os.Create("./testdata/large_file.txt")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create temp file: %v", err)
|
t.Fatalf("Failed to create temp file: %v", err)
|
||||||
}
|
}
|
||||||
@ -126,8 +123,8 @@ func TestUploadFileCancel(t *testing.T) {
|
|||||||
|
|
||||||
channelError := make(chan error, 1)
|
channelError := make(chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
_, e := codex.UploadFile(ctx, UploadOptions{Filepath: tmpFile.Name()})
|
_, err := codex.UploadFile(ctx, UploadOptions{Filepath: tmpFile.Name()})
|
||||||
channelError <- e
|
channelError <- err
|
||||||
}()
|
}()
|
||||||
|
|
||||||
cancel()
|
cancel()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user