Add server settings view (#768)

This commit is contained in:
Dan Sosedoff
2024-12-15 14:46:01 -08:00
committed by GitHub
parent e6df3d19fa
commit f5f78eb32e
8 changed files with 61 additions and 2 deletions

View File

@@ -386,6 +386,10 @@ func (client *Client) TablesStats() (*Result, error) {
return client.query(statements.TablesStats)
}
func (client *Client) ServerSettings() (*Result, error) {
return client.query(statements.Settings)
}
// Returns all active queriers on the server
func (client *Client) Activity() (*Result, error) {
if client.serverType == cockroachType {

View File

@@ -11,10 +11,10 @@ import (
"testing"
"time"
"github.com/sosedoff/pgweb/pkg/command"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/sosedoff/pgweb/pkg/command"
)
var (
@@ -717,6 +717,32 @@ func testConnContext(t *testing.T) {
assert.Equal(t, "default", result.Mode)
}
func testServerSettings(t *testing.T) {
expectedColumns := []string{
"name",
"setting",
"unit",
"category",
"short_desc",
"extra_desc",
"context",
"vartype",
"source",
"min_val",
"max_val",
"enumvals",
"boot_val",
"reset_val",
"sourcefile",
"sourceline",
"pending_restart",
}
result, err := testClient.ServerSettings()
assert.NoError(t, err)
assert.Equal(t, expectedColumns, result.Columns)
}
func TestAll(t *testing.T) {
if onWindows() {
t.Log("Unit testing on Windows platform is not supported.")
@@ -756,6 +782,7 @@ func TestAll(t *testing.T) {
testDumpExport(t)
testTablesStats(t)
testConnContext(t)
testServerSettings(t)
teardownClient()
teardown(t, true)