mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-27 16:07:42 +08:00
gateway: bring back TestGatewayGet test
License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
This commit is contained in:
@ -37,7 +37,7 @@ func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Pa
|
|||||||
return errors.New("not implemented for mockNamesys")
|
return errors.New("not implemented for mockNamesys")
|
||||||
}
|
}
|
||||||
|
|
||||||
func newNodeWithMockNamesys(t *testing.T, ns mockNamesys) *core.IpfsNode {
|
func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) {
|
||||||
c := config.Config{
|
c := config.Config{
|
||||||
Identity: config.Identity{
|
Identity: config.Identity{
|
||||||
PeerID: "Qmfoo", // required by offline node
|
PeerID: "Qmfoo", // required by offline node
|
||||||
@ -49,10 +49,10 @@ func newNodeWithMockNamesys(t *testing.T, ns mockNamesys) *core.IpfsNode {
|
|||||||
}
|
}
|
||||||
n, err := core.NewIPFSNode(context.Background(), core.Offline(r))
|
n, err := core.NewIPFSNode(context.Background(), core.Offline(r))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
n.Namesys = ns
|
n.Namesys = ns
|
||||||
return n
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type delegatedHandler struct {
|
type delegatedHandler struct {
|
||||||
@ -64,14 +64,19 @@ func (dh *delegatedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGatewayGet(t *testing.T) {
|
func TestGatewayGet(t *testing.T) {
|
||||||
t.Skip("not sure whats going on here")
|
// mock node and namesys
|
||||||
ns := mockNamesys{}
|
ns := mockNamesys{}
|
||||||
n := newNodeWithMockNamesys(t, ns)
|
n, err := newNodeWithMockNamesys(ns)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// mock ipfs object
|
||||||
k, err := coreunix.Add(n, strings.NewReader("fnord"))
|
k, err := coreunix.Add(n, strings.NewReader("fnord"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ns["example.com"] = path.FromString("/ipfs/" + k)
|
ns["/ipns/example.com"] = path.FromString("/ipfs/" + k)
|
||||||
|
|
||||||
// need this variable here since we need to construct handler with
|
// need this variable here since we need to construct handler with
|
||||||
// listener, and server with handler. yay cycles.
|
// listener, and server with handler. yay cycles.
|
||||||
|
Reference in New Issue
Block a user