Path: blob/main/component/common/loki/client/logger_test.go
4096 views
package client12// This code is copied from Promtail. The client package is used to configure3// and run the clients that can send log entries to a Loki instance.45import (6"net/url"7"testing"8"time"910"github.com/grafana/agent/component/common/loki"11cortexflag "github.com/grafana/dskit/flagext"12"github.com/grafana/loki/pkg/logproto"13util_log "github.com/grafana/loki/pkg/util/log"14"github.com/prometheus/common/model"15"github.com/stretchr/testify/require"16)1718func TestNewLogger(t *testing.T) {19_, err := NewLogger(nilMetrics, nil, util_log.Logger, []Config{}...)20require.Error(t, err)2122l, err := NewLogger(nilMetrics, nil, util_log.Logger, []Config{{URL: cortexflag.URLValue{URL: &url.URL{Host: "string"}}}}...)23require.NoError(t, err)24l.Chan() <- loki.Entry{Labels: model.LabelSet{"foo": "bar"}, Entry: logproto.Entry{Timestamp: time.Now(), Line: "entry"}}25l.Stop()26}272829