Commit 5bc85423 authored by santiaago's avatar santiaago
Browse files

test testing pkg

parent 52f1a4e2
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
package testing

import (
	"fmt"
	"net/http"
	"testing"

	"github.com/taironas/route"
)

func TestGenerateHandlerFunc(t *testing.T) {

	handler := func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "hello, world")
	}

	r := new(route.Router)
	r.HandleFunc("/test", handler)

	test := GenerateHandlerFunc(t, handler)

	recorder := test("/test", "GET", map[string]string{}, r)
	if recorder.Code != http.StatusOK {
		t.Errorf("returned %v. Expected %v.", recorder.Code, http.StatusOK)
	}
}