mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-02 03:28:25 +08:00
commands/files: Fixed tests
This commit is contained in:
@ -2,6 +2,7 @@ package files
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -10,9 +11,9 @@ import (
|
||||
func TestSliceFiles(t *testing.T) {
|
||||
name := "testname"
|
||||
files := []File{
|
||||
&ReaderFile{"file.txt", strings.NewReader("Some text!\n")},
|
||||
&ReaderFile{"beep.txt", strings.NewReader("beep")},
|
||||
&ReaderFile{"boop.txt", strings.NewReader("boop")},
|
||||
&ReaderFile{"file.txt", ioutil.NopCloser(strings.NewReader("Some text!\n"))},
|
||||
&ReaderFile{"beep.txt", ioutil.NopCloser(strings.NewReader("beep"))},
|
||||
&ReaderFile{"boop.txt", ioutil.NopCloser(strings.NewReader("boop"))},
|
||||
}
|
||||
buf := make([]byte, 20)
|
||||
|
||||
@ -54,7 +55,7 @@ func TestSliceFiles(t *testing.T) {
|
||||
|
||||
func TestReaderFiles(t *testing.T) {
|
||||
message := "beep boop"
|
||||
rf := &ReaderFile{"file.txt", strings.NewReader(message)}
|
||||
rf := &ReaderFile{"file.txt", ioutil.NopCloser(strings.NewReader(message))}
|
||||
buf := make([]byte, len(message))
|
||||
|
||||
if rf.IsDirectory() {
|
||||
|
@ -2,6 +2,7 @@ package http
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -12,12 +13,12 @@ import (
|
||||
func TestOutput(t *testing.T) {
|
||||
text := "Some text! :)"
|
||||
fileset := []files.File{
|
||||
&files.ReaderFile{"file.txt", strings.NewReader(text)},
|
||||
&files.ReaderFile{"file.txt", ioutil.NopCloser(strings.NewReader(text))},
|
||||
&files.SliceFile{"boop", []files.File{
|
||||
&files.ReaderFile{"boop/a.txt", strings.NewReader("bleep")},
|
||||
&files.ReaderFile{"boop/b.txt", strings.NewReader("bloop")},
|
||||
&files.ReaderFile{"boop/a.txt", ioutil.NopCloser(strings.NewReader("bleep"))},
|
||||
&files.ReaderFile{"boop/b.txt", ioutil.NopCloser(strings.NewReader("bloop"))},
|
||||
}},
|
||||
&files.ReaderFile{"beep.txt", strings.NewReader("beep")},
|
||||
&files.ReaderFile{"beep.txt", ioutil.NopCloser(strings.NewReader("beep"))},
|
||||
}
|
||||
sf := &files.SliceFile{"", fileset}
|
||||
buf := make([]byte, 20)
|
||||
|
Reference in New Issue
Block a user