|
|
|
|
|
|
|
|
|
|
|
package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
|
"encoding/json" |
|
|
|
|
|
"testing" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func TestDecodeSubscribed(t *testing.T) { |
|
|
|
|
|
msg := ` |
|
|
|
|
|
{ |
|
|
|
|
|
"id": "5958874da01cc362f", |
|
|
|
|
|
"name": "somename", |
|
|
|
|
|
"deleted": false, |
|
|
|
|
|
"description": null, |
|
|
|
|
|
"createdAt": "2017-07-02 05:40:29", |
|
|
|
|
|
"modifiedAt": "2017-07-02 06:23:20", |
|
|
|
|
|
"openID": "someidea2", |
|
|
|
|
|
"createdById": "1", |
|
|
|
|
|
"createdByName": "Admin", |
|
|
|
|
|
"modifiedById": "1", |
|
|
|
|
|
"modifiedByName": "Admin", |
|
|
|
|
|
"assignedUserId": "1", |
|
|
|
|
|
"assignedUserName": "Admin", |
|
|
|
|
|
"subscribed": false, |
|
|
|
|
|
"teamsIds": [ |
|
|
|
|
|
"5958913a2479166db", |
|
|
|
|
|
"59589145af954bc38" |
|
|
|
|
|
], |
|
|
|
|
|
"teamsNames": { |
|
|
|
|
|
"5958913a2479166db": "testteam1", |
|
|
|
|
|
"59589145af954bc38": "testteam2" |
|
|
|
|
|
} |
|
|
|
|
|
}` |
|
|
|
|
|
|
|
|
|
|
|
e := crmdSubscribe{} |
|
|
|
|
|
err := json.Unmarshal([]byte(msg), &e) |
|
|
|
|
|
AssertEqual(t, err, nil, "decode json entity should be nil") |
|
|
|
|
|
AssertEqual(t, e.ID, "5958874da01cc362f", "") |
|
|
|
|
|
AssertEqual(t, e.Deleted, false, "") |
|
|
|
|
|
AssertEqual(t, e.Description, "", "") |
|
|
|
|
|
AssertEqual(t, e.CreatedAt, "2017-07-02 05:40:29", "") |
|
|
|
|
|
AssertEqual(t, e.ModifiedAt, "2017-07-02 06:23:20", "") |
|
|
|
|
|
AssertEqual(t, e.OpenID, "someidea2", "") |
|
|
|
|
|
AssertEqual(t, e.Subscribed, false, "") |
|
|
|
|
|
AssertEqual(t, e.CreatedByID, "1", "") |
|
|
|
|
|
AssertEqual(t, e.CreatedByName, "Admin", "") |
|
|
|
|
|
AssertEqual(t, e.ModifiedByID, "1", "") |
|
|
|
|
|
AssertEqual(t, e.ModifiedByName, "Admin", "") |
|
|
|
|
|
AssertEqual(t, e.AssignedUserID, "1", "") |
|
|
|
|
|
AssertEqual(t, e.AssignedUserName, "Admin", "") |
|
|
|
|
|
AssertEqual(t, e.TeamsIDs[0], "5958913a2479166db", "") |
|
|
|
|
|
AssertEqual(t, e.TeamsIDs[1], "59589145af954bc38", "") |
|
|
|
|
|
AssertEqual(t, e.TeamsNames["5958913a2479166db"], "testteam1", "") |
|
|
|
|
|
AssertEqual(t, e.TeamsNames["59589145af954bc38"], "testteam2", "") |
|
|
|
|
|
} |