1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- // Copyright The OpenTelemetry Authors
- // SPDX-License-Identifier: Apache-2.0
- package redisreceiver
- import (
- "os"
- "path/filepath"
- "runtime"
- "strings"
- "testing"
- "github.com/stretchr/testify/require"
- )
- var _ client = (*fakeClient)(nil)
- type fakeClient struct{}
- func newFakeClient() *fakeClient {
- return &fakeClient{}
- }
- func (c fakeClient) delimiter() string {
- if runtime.GOOS == "windows" {
- return "\r\n"
- }
- return "\n"
- }
- func (fakeClient) retrieveInfo() (string, error) {
- return readFile("info")
- }
- func (fakeClient) close() error {
- return nil
- }
- func readFile(fname string) (string, error) {
- file, err := os.ReadFile(filepath.Join("testdata", fname+".txt"))
- if err != nil {
- return "", err
- }
- return string(file), nil
- }
- func TestRetrieveInfo(t *testing.T) {
- g := fakeClient{}
- res, err := g.retrieveInfo()
- require.Nil(t, err)
- require.True(t, strings.HasPrefix(res, "# Server"))
- }
|