-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands_test.go
More file actions
48 lines (39 loc) · 861 Bytes
/
commands_test.go
File metadata and controls
48 lines (39 loc) · 861 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
package main
import (
"bytes"
"net/http"
"testing"
)
func TestExit(t *testing.T) {
/*
there's nothing to test in exit
it should be tested manually
*/
t.Logf("meow!")
}
func TestHelp(t *testing.T) {
t.Run("is it printing the right help message", func(t *testing.T) {
buf := new(bytes.Buffer)
err := commandHelpMock(buf)
if err != nil {
t.Fatal(err)
}
if buf.String() != helpMessage {
t.Errorf("help message does not match the expected output")
}
})
}
func TestMap(t *testing.T) {
client := http.Client{}
t.Run("test API status", func(t *testing.T) {
pdclient := NewPokeDexClient()
req, _ := http.NewRequest(http.MethodGet, pdclient.baseURL, nil)
res, err := client.Do(req)
if err != nil {
t.Fatal(err)
}
if res.StatusCode != http.StatusOK {
t.Errorf("status code does not match the expected")
}
})
}