storj/storagenode/console/consoleserver/server_test.go
Egon Elbre 10372afbe4 ci: fix lint errors
Change-Id: Ib5893440807811f77175ccd347aa3f8ca9cccbdf
2021-05-17 13:37:31 +00:00

52 lines
1.4 KiB
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package consoleserver_test
import (
"fmt"
"net/http"
"testing"
"github.com/stretchr/testify/require"
"storj.io/common/testcontext"
"storj.io/storj/private/testplanet"
)
func TestConsole(t *testing.T) {
testplanet.Run(t,
testplanet.Config{
SatelliteCount: 1,
StorageNodeCount: 1,
},
func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
satellite := planet.Satellites[0]
console := planet.StorageNodes[0].Console
addr := console.Listener.Addr()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("http://%s/api/sno", addr), nil)
require.NoError(t, err)
res, err := http.DefaultClient.Do(req)
require.NoError(t, err)
_ = res.Body.Close()
require.Equal(t, http.StatusOK, res.StatusCode)
req, err = http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("http://%s/api/sno/satellites", addr), nil)
require.NoError(t, err)
res, err = http.DefaultClient.Do(req)
require.NoError(t, err)
_ = res.Body.Close()
require.Equal(t, http.StatusOK, res.StatusCode)
req, err = http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("http://%s/api/sno/satellite/%s", addr, satellite.ID()), nil)
require.NoError(t, err)
res, err = http.DefaultClient.Do(req)
require.NoError(t, err)
_ = res.Body.Close()
require.Equal(t, http.StatusOK, res.StatusCode)
},
)
}