mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-05 02:59:44 -06:00
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package datas
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/attic-labs/noms/Godeps/_workspace/src/github.com/stretchr/testify/suite"
|
|
"github.com/attic-labs/noms/chunks"
|
|
)
|
|
|
|
func TestHttpStoreTestSuite(t *testing.T) {
|
|
suite.Run(t, &HttpStoreTestSuite{})
|
|
}
|
|
|
|
type HttpStoreTestSuite struct {
|
|
chunks.ChunkStoreTestSuite
|
|
server *dataStoreServer
|
|
}
|
|
|
|
func (suite *HttpStoreTestSuite) SetupTest() {
|
|
suite.Store = chunks.NewHttpStore("http://localhost:8000")
|
|
suite.server = NewDataStoreServer(NewDataStore(chunks.NewMemoryStore()), 8000)
|
|
go suite.server.Run()
|
|
|
|
// This call to a non-existing URL allows us to exit being sure that the server started. Otherwise, we sometimes get races with Stop() below.
|
|
req, err := http.NewRequest("GET", "http://localhost:8000/notHere", nil)
|
|
suite.NoError(err)
|
|
http.DefaultClient.Do(req)
|
|
}
|
|
|
|
func (suite *HttpStoreTestSuite) TearDownTest() {
|
|
suite.Store.Close()
|
|
suite.server.Stop()
|
|
|
|
// Stop may have closed its side of an existing KeepAlive socket. In that case, the next call will clear the pending failure.
|
|
req, err := http.NewRequest("GET", "http://localhost:8000/notHere", nil)
|
|
suite.NoError(err)
|
|
http.DefaultClient.Do(req)
|
|
}
|