tusd/get_test.go

46 lines
690 B
Go
Raw Normal View History

2015-02-09 18:37:06 +00:00
package tusd
import (
"io"
"net/http"
"os"
"strings"
"testing"
)
type getStore struct {
zeroStore
}
func (s getStore) GetInfo(id string) (FileInfo, error) {
if id != "yes" {
return FileInfo{}, os.ErrNotExist
}
return FileInfo{
Offset: 5,
Size: 20,
}, nil
}
func (s getStore) GetReader(id string) (io.Reader, error) {
return strings.NewReader("hello"), nil
}
2015-02-12 15:05:54 +00:00
func TestGet(t *testing.T) {
2015-02-09 18:37:06 +00:00
handler, _ := NewHandler(Config{
DataStore: getStore{},
})
2015-02-17 14:44:12 +00:00
(&httpTest{
Name: "Successful download",
Method: "GET",
URL: "yes",
Code: http.StatusOK,
ResBody: "hello",
ResHeader: map[string]string{
"Content-Length": "5",
},
}).Run(handler, t)
2015-02-09 18:37:06 +00:00
}