2013-12-23 21:52:10 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
2013-12-24 00:20:51 +00:00
|
|
|
"bytes"
|
|
|
|
"encoding/json"
|
|
|
|
"io"
|
|
|
|
"io/ioutil"
|
2013-12-23 21:52:10 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func makeHTTPServer(t *testing.T) (string, *HTTPServer) {
|
|
|
|
conf := nextConfig()
|
|
|
|
dir, agent := makeAgent(t, conf)
|
2014-01-02 19:45:58 +00:00
|
|
|
server, err := NewHTTPServer(agent, agent.logOutput, conf.HTTPAddr)
|
2013-12-23 21:52:10 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
return dir, server
|
|
|
|
}
|
2013-12-24 00:20:51 +00:00
|
|
|
|
|
|
|
func encodeReq(obj interface{}) io.ReadCloser {
|
|
|
|
buf := bytes.NewBuffer(nil)
|
|
|
|
enc := json.NewEncoder(buf)
|
|
|
|
enc.Encode(obj)
|
|
|
|
return ioutil.NopCloser(buf)
|
|
|
|
}
|