test(e2e): test uploading randomly (#53)

This commit is contained in:
Hexxa 2021-05-13 17:06:00 +08:00 committed by GitHub
parent 36844eb2e0
commit 68548051d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 85 additions and 1 deletions

View file

@ -1,10 +1,13 @@
package server
import (
"io/ioutil"
"path"
"time"
"github.com/ihexxa/gocfg"
"github.com/ihexxa/quickshare/src/client"
fspkg "github.com/ihexxa/quickshare/src/fs"
)
func startTestServer(config string) *Server {
@ -47,3 +50,17 @@ func waitForReady(addr string) bool {
return false
}
func compareFileContent(fs fspkg.ISimpleFS, filePath string, expectedContent string) (bool, error) {
reader, err := fs.GetFileReader(path.Join("files", filePath))
if err != nil {
return false, err
}
gotContent, err := ioutil.ReadAll(reader)
if err != nil {
return false, err
}
return string(gotContent) == expectedContent, nil
}