-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfs_test.go
More file actions
51 lines (45 loc) · 1.36 KB
/
fs_test.go
File metadata and controls
51 lines (45 loc) · 1.36 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package simba_test
import (
"fmt"
"testing"
"time"
"github.com/saisona/simba"
)
func TestDownloadFileNoUrl(t *testing.T) {
dest := fmt.Sprintf("/tmp/%d.dat", time.Now().UnixMilli())
t.Log(dest)
err := simba.DownloadFile(dest, "", false)
if err == nil || err.Error() != "Get \"\": unsupported protocol scheme \"\"" {
t.Fatalf("got: %s, wanted : nil", err.Error())
}
}
func TestDownloadFileOverideSuccess(t *testing.T) {
tmpDir := t.TempDir()
dest := fmt.Sprintf("%s/%d.dat", tmpDir, time.Now().UnixMilli())
t.Log(dest)
err := simba.DownloadFile(dest, "http://www.ovh.net/files/1Mio.dat", true)
if err != nil {
t.Fatalf("got: %s, wanted : nil", err.Error())
}
}
func TestDownloadFileAlreadyExists(t *testing.T) {
tmpDir := t.TempDir()
dest := fmt.Sprintf("%s/%d.dat", tmpDir, time.Now().UnixMilli())
t.Log(dest)
err := simba.DownloadFile(dest, "http://www.ovh.net/files/1Mio.dat", true)
if err != nil {
t.Fatalf("got: %s, wanted : nil", err.Error())
}
err = simba.DownloadFile(dest, "http://www.ovh.net/files/1Mio.dat", false)
if err != nil {
t.Fatalf("got: %s, wanted : nil", err.Error())
}
}
func TestDownloadFileSuccess(t *testing.T) {
dest := fmt.Sprintf("/tmp/%d.dat", time.Now().UnixMilli())
t.Log(dest)
err := simba.DownloadFile(dest, "http://www.ovh.net/files/1Mio.dat", false)
if err != nil {
t.Fatalf("got: %s, wanted : nil", err.Error())
}
}