-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcowyo_test.go
53 lines (45 loc) · 996 Bytes
/
cowyo_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
package main
import (
"io/ioutil"
"os"
"testing"
"github.com/schollz/lumber"
)
var SERVER_STRING string
func init() {
SERVER_STRING = "localhost:8050"
}
func TestCowyo(t *testing.T) {
log = lumber.NewConsoleLogger(lumber.TRACE)
exists, err := pageExists(SERVER_STRING, "alsdkfjalksdfjlaf")
if err != nil {
t.Error(err)
}
if exists != false {
t.Error("alsdkfjalksdfjlaf should not exist!")
}
err = uploadData(SERVER_STRING, "testpage", "codename", "testtext", false, true)
if err != nil {
t.Error(err)
}
exists, err = pageExists(SERVER_STRING, "codename")
if err != nil {
t.Error(err)
}
if exists != true {
t.Error("codename should exist!")
}
err = downloadData(SERVER_STRING, "codename", "")
if err != nil {
t.Error(err)
}
// should write to a file called "testpage"
d, err := ioutil.ReadFile("testpage")
if err != nil {
t.Error(err)
}
if string(d) != "testtext" {
t.Errorf("Got [%s] instead of testtext", string(d))
}
os.Remove("testpage")
}