mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-29 10:32:36 +08:00
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
// Copyright 2024 Kelvin Clement Mwinuka
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package admin
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"fmt"
|
|
"github.com/echovault/echovault/internal"
|
|
"github.com/echovault/echovault/pkg/echovault"
|
|
"github.com/echovault/echovault/pkg/utils"
|
|
"github.com/tidwall/resp"
|
|
"testing"
|
|
)
|
|
|
|
func Test_CommandsHandler(t *testing.T) {
|
|
mockServer := echovault.NewEchoVault(
|
|
echovault.WithConfig(internal.Config{
|
|
DataDir: "",
|
|
EvictionPolicy: utils.NoEviction,
|
|
}),
|
|
echovault.WithCommands(Commands()),
|
|
)
|
|
|
|
res, err := handleGetAllCommands(context.Background(), []string{"commands"}, mockServer, nil)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
rd := resp.NewReader(bytes.NewReader(res))
|
|
rv, _, err := rd.ReadValue()
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
for _, element := range rv.Array() {
|
|
fmt.Println(element)
|
|
}
|
|
}
|