-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
36 lines (30 loc) · 860 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"io/ioutil"
"os"
"testing"
"time"
"github.com/emil-nasso/share/client"
"github.com/emil-nasso/share/server"
)
func TestFullStack(t *testing.T) {
//Start the server
server := server.New()
go server.Start()
//HACK: return a channel
time.Sleep(time.Second)
timestamp := string(time.Now().Unix())
uploaderDirectory := "/tmp/share-test-data/" + timestamp + "/uploader/"
uploaderFile := uploaderDirectory + "/test.txt"
os.MkdirAll(uploaderDirectory, 0777)
ioutil.WriteFile(uploaderFile, []byte(timestamp), 0777)
uploader := client.New("127.0.0.1")
sessionID := uploader.RequestUpload()
defer uploader.Disconnect()
go uploader.WaitAndSendFile(uploaderFile)
//HACK: return a channel
time.Sleep(time.Second)
downloader := client.New("127.0.0.1")
defer downloader.Disconnect()
downloader.RequestDownload(sessionID)
}