This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoZippy_test.go
77 lines (68 loc) · 1.66 KB
/
GoZippy_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"fmt"
"github.com/Arion-Kun/GoZippy/FragmentVariants/Utilities"
"os"
"testing"
)
var Test_Links = []string{
"https://www16.zippyshare.com/v/0rQyN0As/file.html",
"https://www3.zippyshare.com/v/CDCi2wVT/file.html",
"https://www57.zippyshare.com/v/FbTM9y9B/file.html",
}
func Test_SiteConnection(t *testing.T) {
var success = false
for _, link := range Test_Links {
_, err1 := GetLinkContent(link)
if err1 == nil {
success = true
return
}
}
if success == false {
t.Error("All links failed the test, the site seems offline.")
}
}
func Test_MakeZippyFile(t *testing.T) {
var success = false
var linkHolder = ""
for _, link := range Test_Links {
sitePtr, err1 := GetLinkContent(link)
if err1 != nil {
continue
}
successful, filePtr := Utilities.TryMakeZippyFile(sitePtr, _GetIterations)
if successful {
success = true
cachedFile = filePtr
return
} else {
linkHolder = link
t.Log(fmt.Sprintf("All iterations failed for %s", link))
}
}
if success == false {
t.Error(fmt.Sprintf("Failed to make zippy file for %s", linkHolder))
}
}
var cachedFile *Utilities.ZippyFile
func Test_DownloadFile(t *testing.T) {
if cachedFile == nil {
t.Error("MakeZippyFile failed, cannot test download.")
return
}
cachedFolderLocation = "."
download = true
t.Log("Downloading", cachedFile.GetEncodedLink())
downloadPath := TryDownload(cachedFile.GetEncodedLink())
if downloadPath == nil {
return
}
// Remove TryDownload Artifacts
e := os.Remove(*downloadPath)
if e != nil {
t.Error("Failed to remove download artifact", *downloadPath)
} else {
t.Log("Removed download artifact from", *downloadPath)
}
}