7
7
"net/http/httptest"
8
8
"testing"
9
9
10
+ "github.com/davecgh/go-spew/spew"
10
11
"github.com/stretchr/testify/assert"
11
12
"github.com/stretchr/testify/require"
12
13
@@ -32,6 +33,7 @@ func configureRequest(httpReq *http.Request) *castle.Request {
32
33
},
33
34
User : castle.User {
34
35
ID : "user-id" ,
36
+
35
37
Traits : map [string ]string {"trait1" : "traitValue1" },
36
38
},
37
39
Properties : map [string ]string {"prop1" : "propValue1" },
@@ -150,7 +152,7 @@ func TestCastle_Filter(t *testing.T) {
150
152
Type castle.EventType `json:"type"`
151
153
Status castle.EventStatus `json:"status"`
152
154
RequestToken string `json:"request_token"`
153
- User castle.User `json:"user "`
155
+ Params castle.UserParams `json:"params "`
154
156
Context * castle.Context `json:"context"`
155
157
Properties map [string ]string `json:"properties"`
156
158
}
@@ -164,13 +166,13 @@ func TestCastle_Filter(t *testing.T) {
164
166
assert .True (t , ok )
165
167
166
168
err = json .NewDecoder (r .Body ).Decode (reqData )
169
+ spew .Dump (reqData )
167
170
require .NoError (t , err )
168
171
169
172
assert .Equal (t , castle .EventTypeLogin , reqData .Type )
170
173
assert .Equal (t , castle .EventStatusSucceeded , reqData .Status )
171
- assert .Equal (t , "user-id " , reqData .User . ID )
174
+ assert .Equal (t , "user@test.com " , reqData .Params . Email )
172
175
assert .Equal (t , map [string ]string {"prop1" : "propValue1" }, reqData .Properties )
173
- assert .Equal (t , map [string ]string {"trait1" : "traitValue1" }, reqData .User .Traits )
174
176
assert .Equal (t , castle .FromHTTPRequest (httpReq ), reqData .Context )
175
177
176
178
executed = true
0 commit comments