forked from mattn/go-redmine
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproject_test.go
72 lines (67 loc) · 1.68 KB
/
project_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
package redmine
import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net/http"
"net/http/httptest"
"testing"
)
func TestClient_Project(t *testing.T) {
t.Run("should parse general project fields, and ignore module names and trackers from http response", func(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprintln(w, `{
"project": {
"id": 1,
"name": "example project",
"identifier": "exampleproject",
"description": "This is an example project.",
"homepage": "http://github.com/cloudogu/go-redmine",
"status": 1,
"is_public": true,
"inherit_members": true,
"trackers": [
{
"id": 1,
"name": "Bug"
},
{
"id": 2,
"name": "Feature"
}
],
"enabled_modules": [
{
"id": 71,
"name": "issue_tracking"
},
{
"id": 73,
"name": "wiki"
}
],
"created_on": "2021-02-19T16:51:03Z",
"updated_on": "2021-02-19T16:51:25Z"
}
}`)
}))
defer ts.Close()
sut := NewClient(ts.URL, "apiKey")
actualProject, err := sut.Project(1)
require.NoError(t, err)
require.NotEmpty(t, actualProject)
expectedProject := &Project{
Id: 1,
ParentID: Id{},
Name: "example project",
Identifier: "exampleproject",
Description: "This is an example project.",
Homepage: "http://github.com/cloudogu/go-redmine",
IsPublic: true,
InheritMembers: true,
CreatedOn: "2021-02-19T16:51:03Z",
UpdatedOn: "2021-02-19T16:51:25Z",
}
assert.Equal(t, expectedProject, actualProject)
})
}