mirror of
https://github.com/kataras/iris.git
synced 2025-12-19 19:07:06 +00:00
reorganization of _examples and add some new examples such as iris+groupcache+mysql+docker
Former-commit-id: ed635ee95de7160cde11eaabc0c1dcb0e460a620
This commit is contained in:
31
_examples/file-server/upload-files/main_test.go
Normal file
31
_examples/file-server/upload-files/main_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/kataras/iris/v12/httptest"
|
||||
)
|
||||
|
||||
func TestUploadFiles(t *testing.T) {
|
||||
app := newApp()
|
||||
e := httptest.New(t, app)
|
||||
|
||||
// upload the file itself.
|
||||
fh, err := os.Open("main.go")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer fh.Close()
|
||||
|
||||
e.POST("/upload").WithMultipart().WithFile("files", "main.go", fh).
|
||||
Expect().Status(httptest.StatusOK)
|
||||
|
||||
f, err := os.Open("uploads/main.go")
|
||||
if err != nil {
|
||||
t.Fatalf("expected file to get actually uploaded on the system directory but: %v", err)
|
||||
}
|
||||
f.Close()
|
||||
|
||||
os.Remove(f.Name())
|
||||
}
|
||||
Reference in New Issue
Block a user