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