mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-11-02 19:07:46 +00:00
add sms test
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -88,3 +91,25 @@ func Test_getJSONPost(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Test_SMS(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
rw.WriteHeader(200)
|
||||
defer req.Body.Close()
|
||||
bodyBytes, _ := ioutil.ReadAll(req.Body)
|
||||
fmt.Printf("body: %s\n", string(bodyBytes))
|
||||
if string(bodyBytes) != "Body=Data+Bunker+code+1234&From=from1234&To=4444" {
|
||||
t.Fatalf("bad request: %s", string(bodyBytes))
|
||||
}
|
||||
}))
|
||||
// Close the server when test finishes
|
||||
defer server.Close()
|
||||
client := server.Client()
|
||||
domain := server.URL
|
||||
var cfg Config
|
||||
cfg.Sms.TwilioToken = "ttoken"
|
||||
cfg.Sms.TwilioAccount = "taccount"
|
||||
cfg.Sms.TwilioFrom = "from1234"
|
||||
sendCodeByPhoneDo(domain, client, 1234, "4444", cfg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user