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)
|
|
|
|
server, err := NewServer(agent, agent.logOutput, conf.HTTPAddr)
|
|
|
|
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)
|
|
|
|
}
|