<commit_before>package test

import (
	"reflect"
	"testing"

	"github.com/PuerkitoBio/gred/cmd"
	_ "github.com/PuerkitoBio/gred/cmd/hashes"
	_ "github.com/PuerkitoBio/gred/cmd/keys"
	_ "github.com/PuerkitoBio/gred/cmd/lists"
	_ "github.com/PuerkitoBio/gred/cmd/sets"
	_ "github.com/PuerkitoBio/gred/cmd/strings"
	"github.com/PuerkitoBio/gred/srv"
)

func TestCommand(t *testing.T) {
	cases := []struct {
		name string
		args []string
		res  interface{}
		err  error
	}{
		// First create a key for all types
		{"set", []string{"s", "val"}, cmd.OKVal, nil},
		{"hset", []string{"h", "f1", "v1"}, true, nil},
		{"lpush", []string{"l", "v1"}, int64(1), nil},
		{"sadd", []string{"t", "v1"}, int64(1), nil},

		// Strings
		{"append", []string{"k", "a"}, int64(1), nil},
		{"append", []string{"k", "bcd"}, int64(4), nil},
		{"append", []string{"t", "bcd"}, nil, cmd.ErrInvalidValType},
		{"get", []string{"k"}, "abcd", nil},
		{"get", []string{"z"}, nil, nil},
		{"get", []string{"l"}, nil, cmd.ErrInvalidValType},
		{"getrange", []string{"k", "2", "4"}, "cd", nil},
		{"getrange", []string{"k", "-1", "4"}, "d", nil},
		{"getrange", []string{"k", "-10", "-40"}, "a", nil},
		{"getrange", []string{"k", "10", "40"}, "", nil},
		{"getrange", []string{"l", "10", "40"}, nil, cmd.ErrInvalidValType},
		{"getset", []string{"k", "efg"}, "abcd", nil},
		{"getset", []string{"z", "efg"}, "", nil},
		{"del", []string{"z"}, int64(1), nil},
		{"getset", []string{"h", "efg"}, nil, cmd.ErrInvalidValType},
		{"set", []string{"h", "efg"}, nil, cmd.ErrInvalidValType},<commit_msg>test connection and server commands<commit_after>package test

import (
	"reflect"
	"testing"

	"github.com/PuerkitoBio/gred/cmd"
	_ "github.com/PuerkitoBio/gred/cmd/connection"
	_ "github.com/PuerkitoBio/gred/cmd/hashes"
	_ "github.com/PuerkitoBio/gred/cmd/keys"
	_ "github.com/PuerkitoBio/gred/cmd/lists"
	_ "github.com/PuerkitoBio/gred/cmd/server"
	_ "github.com/PuerkitoBio/gred/cmd/sets"
	_ "github.com/PuerkitoBio/gred/cmd/strings"
	"github.com/PuerkitoBio/gred/srv"
)

func TestCommand(t *testing.T) {
	cases := []struct {
		name string
		args []string
		res  interface{}
		err  error
	}{
		// Server commands
		{"flushall", []string{}, cmd.OKVal, nil},
		{"flushdb", []string{}, cmd.OKVal, nil},

		// Connection commands
		{"echo", []string{"test"}, "test", nil},
		{"ping", []string{}, cmd.PongVal, nil},
		{"select", []string{"0"}, cmd.OKVal, nil},
		{"quit", []string{}, nil, cmd.ErrQuit},

		// First create a key for all types
		{"set", []string{"s", "val"}, cmd.OKVal, nil},
		{"hset", []string{"h", "f1", "v1"}, true, nil},
		{"lpush", []string{"l", "v1"}, int64(1), nil},
		{"sadd", []string{"t", "v1"}, int64(1), nil},

		// Strings
		{"append", []string{"k", "a"}, int64(1), nil},
		{"append", []string{"k", "bcd"}, int64(4), nil},
		{"append", []string{"t", "bcd"}, nil, cmd.ErrInvalidValType},
		{"get", []string{"k"}, "abcd", nil},
		{"get", []string{"z"}, nil, nil},
		{"get", []string{"l"}, nil, cmd.ErrInvalidValType},
		{"getrange", []string{"k", "2", "4"}, "cd", nil},
		{"getrange", []string{"k", "-1", "4"}, "d", nil},
		{"getrange", []string{"k", "-10", "-40"}, "a", nil},
		{"getrange", []string{"k", "10", "40"}, "", nil},
		{"getrange", []string{"l", "10", "40"}, nil, cmd.ErrInvalidValType},
		{"getset", []string{"k", "efg"}, "abcd", nil},
		{"getset", []string{"z", "efg"}, "", nil},
		{"del", []string{"z"}, int64(1), nil},
		{"getset", []string{"h", "efg"}, nil, cmd.ErrInvalidValType},
		{"set", []string{"h", "efg"}, nil, cmd.ErrInvalidValType},
{'fraction_non_alphanumeric': 0.2848689771766695, 'fraction_numerical': 0.020005635390250773, 'mean_word_length': 4.877483443708609, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3678834', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1420, 'n_words': 299}