-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_test.go
More file actions
52 lines (39 loc) · 967 Bytes
/
create_test.go
File metadata and controls
52 lines (39 loc) · 967 Bytes
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
package phant
import (
"fmt"
"net/http"
"testing"
)
func TestCreate_ReturnACorrectResponse(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusAccepted)
fmt.Fprintf(w, `{"success":true,"publicKey":"123","privateKey":"456","deleteKey":"789"}`)
})
res, err := CreateStream("title", "description", []string{}, []string{}, true)
if err != nil {
t.Error("expected no error")
}
if res.DeleteKey != "789" {
t.Error("delete key not set")
}
if res.PrivateKey != "456" {
t.Error("private key not set")
}
if res.PublicKey != "123" {
t.Error("public key not set")
}
}
func TestCreate_ReturnAnError(t *testing.T) {
setup()
defer teardown()
handleError()
_, err := CreateStream("title", "description", []string{}, []string{}, true)
if err == nil {
t.Error("expected error")
}
if err.Error() != "not ok" {
t.Error("expected 'not ok' in error")
}
}