<commit_before>// Copyright 2015 Reborndb Org. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.

package utils

/*
const (
	redisAddr = ":6379"
)

func TestSlotSize(t *testing.T) {
	c, _ := redis.Dial("tcp", redisAddr)
	defer c.Close()

	ret, err := SlotsInfo(redisAddr, 1023, 0)
	log.Info(len(ret))

	if err == nil {
		t.Error("should be error")
	}
}

func TestStat(t *testing.T) {
	log.Info(GetRedisStat(redisAddr))
}
*/<commit_msg>add some tests for ping and get info<commit_after>// Copyright 2015 Reborndb Org. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.

package utils

import (
	"testing"

	"github.com/alicebob/miniredis"
	. "gopkg.in/check.v1"
)

func TestT(t *testing.T) {
	TestingT(t)
}

type testUtilsSuite struct {
	r    *miniredis.Miniredis
	addr string
	auth string
}

func (s *testUtilsSuite) SetUpSuite(c *C) {
	var err error
	s.r, err = miniredis.Run()
	c.Assert(err, IsNil)

	s.addr = s.r.Addr()
	s.auth = "abc"
	s.r.RequireAuth(s.auth)
}

func (s *testUtilsSuite) TearDownSuite(c *C) {
	if s.r != nil {
		s.r.Close()
		s.r = nil
	}
}

func (s *testUtilsSuite) TestPing(c *C) {
	err := Ping(s.addr, s.auth)
	c.Assert(err, IsNil)
}

func (s *testUtilsSuite) TestGetInfo(c C) {
	_, err := GetRedisInfo(s.addr, "", s.auth)
	c.Assert(err, IsNil)
}
{'fraction_non_alphanumeric': 0.15793470007593013, 'fraction_numerical': 0.01366742596810934, 'mean_word_length': 3.673758865248227, 'pattern_counts': {'":': 1, '<': 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': '5911771', 'n_tokens_mistral': 577, 'n_tokens_neox': 553, 'n_words': 132}