-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtaxonomies_test.go
57 lines (47 loc) · 1.3 KB
/
taxonomies_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
package wordpress_test
import (
"net/http"
"testing"
)
func TestTaxonomiesList(t *testing.T) {
wp, ctx := initTestClient()
taxonomies, resp, err := wp.Taxonomies.List(ctx, nil)
if err != nil {
t.Errorf("Should not return error: %v", err.Error())
}
if resp != nil && resp.StatusCode != http.StatusOK {
t.Errorf("Expected 200 OK, got %v", resp.Status)
}
if taxonomies == nil {
t.Errorf("Should not return nil taxonomies")
}
if len(taxonomies) != 2 {
t.Errorf("Should return two taxonomies")
}
}
func TestTaxonomiesGet_TaxonomyExists(t *testing.T) {
wp, ctx := initTestClient()
taxonomy, resp, err := wp.Taxonomies.Get(ctx, "post_tag", nil)
if err != nil {
t.Errorf("Should not return error: %v", err.Error())
}
if resp != nil && resp.StatusCode != http.StatusOK {
t.Errorf("Expected 200 OK, got %v", resp.Status)
}
if taxonomy == nil {
t.Errorf("Should not return nil taxonomies")
}
}
func TestTaxonomiesGet_TaxonomyDoesNotExists(t *testing.T) {
wp, ctx := initTestClient()
taxonomy, resp, err := wp.Taxonomies.Get(ctx, "RANDOM", nil)
if err == nil {
t.Errorf("Should return error")
}
if resp != nil && resp.StatusCode != http.StatusNotFound {
t.Errorf("Expected 404 Not Found, got %v", resp.Status)
}
if taxonomy == nil {
t.Errorf("Should not return nil taxonomies")
}
}