Commit 2b5b0ea9 authored by Janos Guljas's avatar Janos Guljas

test exported functionality explicitly in api and debugapi packages

parent 1b8135c0
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package api
package api_test
import (
"io/ioutil"
......@@ -11,6 +11,7 @@ import (
"net/url"
"testing"
"github.com/ethersphere/bee/pkg/api"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/pingpong"
"resenje.org/web"
......@@ -21,7 +22,7 @@ type testServerOptions struct {
}
func newTestServer(t *testing.T, o testServerOptions) (client *http.Client, cleanup func()) {
s := New(Options{
s := api.New(api.Options{
Pingpong: o.Pingpong,
Logger: logging.New(ioutil.Discard),
})
......
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package api
type PingpongResponse = pingpongResponse
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package api
package api_test
import (
"context"
......@@ -11,6 +11,7 @@ import (
"testing"
"time"
"github.com/ethersphere/bee/pkg/api"
"github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
"github.com/ethersphere/bee/pkg/p2p"
......@@ -40,7 +41,7 @@ func TestPingpong(t *testing.T) {
defer cleanup()
t.Run("ok", func(t *testing.T) {
jsonhttptest.ResponseDirect(t, client, http.MethodPost, "/pingpong/"+peerID, nil, http.StatusOK, pingpongResponse{
jsonhttptest.ResponseDirect(t, client, http.MethodPost, "/pingpong/"+peerID, nil, http.StatusOK, api.PingpongResponse{
RTT: rtt,
})
})
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package debugapi
package debugapi_test
import (
"io/ioutil"
......@@ -11,6 +11,7 @@ import (
"net/url"
"testing"
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
"resenje.org/web"
......@@ -21,7 +22,7 @@ type testServerOptions struct {
}
func newTestServer(t *testing.T, o testServerOptions) (client *http.Client, cleanup func()) {
s := New(Options{
s := debugapi.New(debugapi.Options{
P2P: o.P2P,
Logger: logging.New(ioutil.Discard),
})
......
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package debugapi
type (
StatusResponse = statusResponse
PeerConnectResponse = peerConnectResponse
)
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package debugapi
package debugapi_test
import (
"context"
......@@ -10,6 +10,7 @@ import (
"net/http"
"testing"
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
"github.com/ethersphere/bee/pkg/p2p/mock"
......@@ -33,7 +34,7 @@ func TestConnect(t *testing.T) {
defer cleanup()
t.Run("ok", func(t *testing.T) {
jsonhttptest.ResponseDirect(t, client, http.MethodPost, "/connect"+underlay, nil, http.StatusOK, peerConnectResponse{
jsonhttptest.ResponseDirect(t, client, http.MethodPost, "/connect"+underlay, nil, http.StatusOK, debugapi.PeerConnectResponse{
Address: overlay,
})
})
......
......@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package debugapi
package debugapi_test
import (
"net/http"
"testing"
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
)
......@@ -15,7 +16,7 @@ func TestHealth(t *testing.T) {
client, cleanup := newTestServer(t, testServerOptions{})
defer cleanup()
jsonhttptest.ResponseDirect(t, client, http.MethodGet, "/health", nil, http.StatusOK, statusResponse{
jsonhttptest.ResponseDirect(t, client, http.MethodGet, "/health", nil, http.StatusOK, debugapi.StatusResponse{
Status: "ok",
})
}
......@@ -24,7 +25,7 @@ func TestReadiness(t *testing.T) {
client, cleanup := newTestServer(t, testServerOptions{})
defer cleanup()
jsonhttptest.ResponseDirect(t, client, http.MethodGet, "/readiness", nil, http.StatusOK, statusResponse{
jsonhttptest.ResponseDirect(t, client, http.MethodGet, "/readiness", nil, http.StatusOK, debugapi.StatusResponse{
Status: "ok",
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment