func (t *testStore) Get(key string) (string, error) {
	return t.m[key], nil
}
Get gets the requested key.
package httpd
import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"
	"testing"
)
func Test_NewServer(t *testing.T) {
	store := newTestStore()
	s := &testServer{New(":0", store)}
	if s == nil {
		t.Fatal("failed to create HTTP service")
	}
	if err := s.Start(); err != nil {
		t.Fatalf("failed to start HTTP service: %s", err)
	}
	b := doGet(t, s.URL(), "k1")
	if string(b) != `{"k1":""}` {
		t.Fatalf("wrong value received for key k1: %s", string(b))
	}
	doPost(t, s.URL(), "k1", "v1")
	b = doGet(t, s.URL(), "k1")
	if string(b) != `{"k1":"v1"}` {
		t.Fatalf("wrong value received for key k1: %s", string(b))
	}
	store.m["k2"] = "v2"
	b = doGet(t, s.URL(), "k2")
	if string(b) != `{"k2":"v2"}` {
		t.Fatalf("wrong value received for key k2: %s", string(b))
	}
	doDelete(t, s.URL(), "k2")
	b = doGet(t, s.URL(), "k2")
	if string(b) != `{"k2":""}` {
		t.Fatalf("wrong value received for key k2: %s", string(b))
	}
}
type testServer struct {
	*Service
}
func (t *testServer) URL() string {
	port := strings.TrimLeft(t.Addr().String(), "[::]:")
	return fmt.Sprintf("http://127.0.0.1:%s", port)
}
type testStore struct {
	m map[string]string
}
func newTestStore() *testStore {
	return &testStore{
		m: make(map[string]string),
	}
}