Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest goflow v0.81.0 #260

Merged
merged 2 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/mattn/go-sqlite3 v1.10.0 // indirect
github.com/nyaruka/ezconf v0.2.1
github.com/nyaruka/gocommon v1.2.0
github.com/nyaruka/goflow v0.80.0
github.com/nyaruka/goflow v0.81.0
github.com/nyaruka/librato v1.0.0
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d
github.com/nyaruka/null v1.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ github.com/nyaruka/ezconf v0.2.1 h1:TDXWoqjqYya1uhou1mAJZg7rgFYL98EB0Tb3+BWtUh0=
github.com/nyaruka/ezconf v0.2.1/go.mod h1:ey182kYkw2MIi4XiWe1FR/mzI33WCmTWuceDYYxgnQw=
github.com/nyaruka/gocommon v1.2.0 h1:gCmVCXYZFwKDMqQj8R1jNlK+7a06khKFq3zX8fBBbzw=
github.com/nyaruka/gocommon v1.2.0/go.mod h1:9Y21Fd6iZXDLHWTRiZAc6b4LQSCi6HEEQK4SB45Yav4=
github.com/nyaruka/goflow v0.80.0 h1:0D+GxRFeWcZP+1vZ9ONzMwaZF0yeFniZQH2r3+8ciSc=
github.com/nyaruka/goflow v0.80.0/go.mod h1:LoRoyfHkJNVEY34AH3qDSDf7Vdq7Ztj47kNx6ceWp4I=
github.com/nyaruka/goflow v0.81.0 h1:RrQsQbrPnxWHW8uYc305JOPrGeQjHadTF2jDXZFjrOI=
github.com/nyaruka/goflow v0.81.0/go.mod h1:LoRoyfHkJNVEY34AH3qDSDf7Vdq7Ztj47kNx6ceWp4I=
github.com/nyaruka/librato v1.0.0 h1:Vznj9WCeC1yZXbBYyYp40KnbmXLbEkjKmHesV/v2SR0=
github.com/nyaruka/librato v1.0.0/go.mod h1:pkRNLFhFurOz0QqBz6/DuTFhHHxAubWxs4Jx+J7yUgg=
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d h1:hyp9u36KIwbTCo2JAJ+TuJcJBc+UZzEig7RI/S5Dvkc=
Expand Down
10 changes: 6 additions & 4 deletions goflow/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestEngineWebhook(t *testing.T) {

defer httpx.SetRequestor(httpx.DefaultRequestor)
httpx.SetRequestor(httpx.NewMockRequestor(map[string][]httpx.MockResponse{
"http://rapidpro.io": []httpx.MockResponse{httpx.NewMockResponse(200, nil, "OK", 1)},
"http://rapidpro.io": []httpx.MockResponse{httpx.NewMockResponse(200, nil, "OK")},
}))

request, err := http.NewRequest("GET", "http://rapidpro.io", nil)
Expand All @@ -29,7 +29,8 @@ func TestEngineWebhook(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, call)
assert.Equal(t, "GET / HTTP/1.1\r\nHost: rapidpro.io\r\nUser-Agent: RapidProMailroom/Dev\r\nX-Mailroom-Mode: normal\r\nAccept-Encoding: gzip\r\n\r\n", string(call.RequestTrace))
assert.Equal(t, "HTTP/1.0 200 OK\r\nContent-Length: 2\r\n\r\nOK", string(call.ResponseTrace))
assert.Equal(t, "HTTP/1.0 200 OK\r\nContent-Length: 2\r\n\r\n", string(call.ResponseTrace))
assert.Equal(t, "OK", string(call.ResponseBody))
}

func TestSimulatorAirtime(t *testing.T) {
Expand All @@ -56,7 +57,7 @@ func TestSimulatorWebhook(t *testing.T) {

defer httpx.SetRequestor(httpx.DefaultRequestor)
httpx.SetRequestor(httpx.NewMockRequestor(map[string][]httpx.MockResponse{
"http://rapidpro.io": []httpx.MockResponse{httpx.NewMockResponse(200, nil, "OK", 1)},
"http://rapidpro.io": []httpx.MockResponse{httpx.NewMockResponse(200, nil, "OK")},
}))

request, err := http.NewRequest("GET", "http://rapidpro.io", nil)
Expand All @@ -66,5 +67,6 @@ func TestSimulatorWebhook(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, call)
assert.Equal(t, "GET / HTTP/1.1\r\nHost: rapidpro.io\r\nUser-Agent: RapidProMailroom/Dev\r\nX-Mailroom-Mode: simulation\r\nAccept-Encoding: gzip\r\n\r\n", string(call.RequestTrace))
assert.Equal(t, "HTTP/1.0 200 OK\r\nContent-Length: 2\r\n\r\nOK", string(call.ResponseTrace))
assert.Equal(t, "HTTP/1.0 200 OK\r\nContent-Length: 2\r\n\r\n", string(call.ResponseTrace))
assert.Equal(t, "OK", string(call.ResponseBody))
}
8 changes: 4 additions & 4 deletions hooks/airtime_transferred_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func TestAirtimeTransferred(t *testing.T) {

httpx.SetRequestor(httpx.NewMockRequestor(map[string][]httpx.MockResponse{
"https://airtime-api.dtone.com/cgi-bin/shop/topup": []httpx.MockResponse{
httpx.NewMockResponse(200, nil, withCRLF(msisdnResponse), 1),
httpx.NewMockResponse(200, nil, withCRLF(reserveResponse), 1),
httpx.NewMockResponse(200, nil, withCRLF(topupResponse), 1),
httpx.NewMockResponse(200, nil, "error_code=13\r\nerror_txt=Oops\r\n", 1),
httpx.NewMockResponse(200, nil, withCRLF(msisdnResponse)),
httpx.NewMockResponse(200, nil, withCRLF(reserveResponse)),
httpx.NewMockResponse(200, nil, withCRLF(topupResponse)),
httpx.NewMockResponse(200, nil, "error_code=13\r\nerror_txt=Oops\r\n"),
},
}))

Expand Down
2 changes: 1 addition & 1 deletion hooks/classifier_called_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestClassifierCalled(t *testing.T) {

httpx.SetRequestor(httpx.NewMockRequestor(map[string][]httpx.MockResponse{
"https://api.wit.ai/message?v=20170307&q=book+me+a+flight": []httpx.MockResponse{
httpx.NewMockResponse(200, nil, `{"_text":"book me a flight","entities":{"intent":[{"confidence":0.84709152161066,"value":"book_flight"}]},"msg_id":"1M7fAcDWag76OmgDI"}`, 1),
httpx.NewMockResponse(200, nil, `{"_text":"book me a flight","entities":{"intent":[{"confidence":0.84709152161066,"value":"book_flight"}]},"msg_id":"1M7fAcDWag76OmgDI"}`),
},
}))

Expand Down
10 changes: 5 additions & 5 deletions hooks/webhook_called_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ func TestWebhookCalled(t *testing.T) {

httpx.SetRequestor(httpx.NewMockRequestor(map[string][]httpx.MockResponse{
"http://rapidpro.io/": []httpx.MockResponse{
httpx.NewMockResponse(200, nil, "OK", 1),
httpx.NewMockResponse(200, nil, "OK", 1),
httpx.NewMockResponse(200, nil, "OK"),
httpx.NewMockResponse(200, nil, "OK"),
},
"http://rapidpro.io/?unsub=1": []httpx.MockResponse{
httpx.NewMockResponse(410, nil, "Gone", 1),
httpx.NewMockResponse(410, nil, "Gone", 1),
httpx.NewMockResponse(410, nil, "Gone", 1),
httpx.NewMockResponse(410, nil, "Gone"),
httpx.NewMockResponse(410, nil, "Gone"),
httpx.NewMockResponse(410, nil, "Gone"),
},
}))

Expand Down