package main

import (
	"bufio"
	"net/http"
	"net/http/httptest"
	"sched/business"
	"strings"
	"testing"
)

func TestHttp(t *testing.T) {
	//t.Errorf("in testHttp")

	main()

	s := "POST / HTTP/1.0\r\n\r\n {\"active_time\": 1460961470, \"roomid\": 50, \"teachers\": \"{\"102\": \"3\", \"100\": \"1\", \"101\": \"2\"}\", \"max_count\": 100}"

	rw := httptest.NewRecorder()

	business.ActiveRoom(rw, req(t, s))
}

func req(t *testing.T, v string) *http.Request {
	req, err := http.ReadRequest(bufio.NewReader(strings.NewReader(v)))
	if err != nil {
		t.Fatal(err)
	}
	return req
}
