feat: fix upload file

This commit is contained in:
Rogee
2025-01-17 15:48:53 +08:00
parent b5583bb34a
commit 5b511a5ea1
5 changed files with 99 additions and 76 deletions

View File

@@ -1,11 +1,15 @@
package main
import (
"os"
"path/filepath"
"testing"
"test/database/models/qvyun_v2/public/table"
. "github.com/go-jet/jet/v2/postgres"
. "github.com/smartystreets/goconvey/convey"
"github.com/spf13/afero"
)
func Test_Join(t *testing.T) {
@@ -18,3 +22,29 @@ func Test_Join(t *testing.T) {
)
t.Log(stmt.DebugSql())
}
func Test_Afero(t *testing.T) {
Convey("Test afero", t, func() {
fs := afero.NewBasePathFs(afero.NewOsFs(), "/tmp")
path := "test/a/b/c/test.txt"
err := fs.MkdirAll(filepath.Dir(path), os.ModePerm)
So(err, ShouldBeNil)
f, err := fs.OpenFile(path, os.O_CREATE|os.O_RDWR, 0o644)
So(err, ShouldBeNil)
f.Write([]byte("hello "))
f.Write([]byte("world"))
f.Close()
ff, err := fs.Open(path)
So(err, ShouldBeNil)
b := make([]byte, 1024)
n, err := ff.Read(b)
So(err, ShouldBeNil)
So(string(b[:n]), ShouldEqual, "hello world")
})
}