Last active
April 12, 2017 01:23
-
-
Save matiasinsaurralde/2bb9f0259581d63fcb33293e9bba35b1 to your computer and use it in GitHub Desktop.
test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package crawl | |
import ( | |
"net/http" | |
"testing" | |
) | |
type testHandler struct { | |
} | |
// Esta funcion va a ser llamada en cada request: | |
func (h testHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
/* Necesitamos responder algo como esto: | |
<br/><p><center>El NIS 1427216 cuenta con 2 facturas pendientes de pago. <br /> Total Gs.: 521.000 comisión incluida. <br />Fecha de vencimiento 2017-04-17</p></center><br /><br /> | |
*/ | |
s := "<br/><p><center>El NIS 1427216 cuenta con 2 facturas pendientes de pago. <br /> Total Gs.: 521.000 comisión incluida. <br />Fecha de vencimiento 2017-04-17</p></center><br /><br />" | |
w.Write([]byte(s)) | |
} | |
func init() { | |
// Con esto hacemos override del valor original de endpointUrl: | |
endpointUrl = "http://localhost:8000/consulta/consulta_02.php" | |
// Corremos un servidor web en el 8000, usando un handler llamado TestHandler. | |
var handler http.Handler | |
handler = testHandler{} | |
go http.ListenAndServe(":8000", handler) | |
} | |
func TestFetchConsumption(t *testing.T) { | |
nis := "123" | |
_, consumption, _, _, _ := FetchConsumption(nis) | |
if consumption != 521000 { | |
t.Fatal("El consumo no coincide") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment