github.com/ethersphere/bee/v2@v2.2.0/pkg/api/debugstorage_test.go (about)

     1  // Copyright 2023 The Swarm Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package api_test
     6  
     7  import (
     8  	"net/http"
     9  	"testing"
    10  
    11  	"github.com/ethersphere/bee/v2/pkg/jsonhttp/jsonhttptest"
    12  	"github.com/ethersphere/bee/v2/pkg/storer"
    13  	mockstorer "github.com/ethersphere/bee/v2/pkg/storer/mock"
    14  )
    15  
    16  func TestDebugStorage(t *testing.T) {
    17  	t.Parallel()
    18  
    19  	t.Run("ok", func(t *testing.T) {
    20  		t.Parallel()
    21  
    22  		want := storer.Info{
    23  			Upload: storer.UploadStat{
    24  				TotalUploaded: 100,
    25  				TotalSynced:   50,
    26  			},
    27  			Cache: storer.CacheStat{
    28  				Size:     50,
    29  				Capacity: 100,
    30  			},
    31  			ChunkStore: storer.ChunkStoreStat{
    32  				TotalChunks: 100,
    33  				SharedSlots: 10,
    34  			},
    35  		}
    36  
    37  		ts, _, _, _ := newTestServer(t, testServerOptions{
    38  			Storer: mockstorer.NewWithDebugInfo(want),
    39  		})
    40  
    41  		jsonhttptest.Request(t, ts, http.MethodGet, "/debugstore", http.StatusOK,
    42  			jsonhttptest.WithExpectedJSONResponse(want),
    43  		)
    44  	})
    45  
    46  }