Skip to content

Commit

Permalink
Fix rebase issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ravishankar15 committed Dec 18, 2024
1 parent 45b21db commit 77997f0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 60 deletions.
51 changes: 51 additions & 0 deletions internal/component/faro/receiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"fmt"
"net/http"
"strings"
"sync"
"testing"
"time"

"github.com/grafana/loki/v3/pkg/logproto"
"github.com/phayes/freeport"
Expand Down Expand Up @@ -139,3 +141,52 @@ func Test(t *testing.T) {
})
}
}

type fakeLogsReceiver struct {
ch chan loki.Entry

entriesMut sync.RWMutex
entries []loki.Entry
}

var _ loki.LogsReceiver = (*fakeLogsReceiver)(nil)

func newFakeLogsReceiver(t *testing.T) *fakeLogsReceiver {
ctx := componenttest.TestContext(t)

lr := &fakeLogsReceiver{
ch: make(chan loki.Entry),
}

go func() {
defer close(lr.ch)

select {
case <-ctx.Done():
return
case ent := <-lr.Chan():
lr.entriesMut.Lock()
lr.entries = append(lr.entries, loki.Entry{
Labels: ent.Labels,
Entry: logproto.Entry{
Timestamp: time.Time{}, // Use consistent time for testing.
Line: ent.Line,
StructuredMetadata: ent.StructuredMetadata,
},
})
lr.entriesMut.Unlock()
}
}()

return lr
}

func (lr *fakeLogsReceiver) Chan() chan loki.Entry {
return lr.ch
}

func (lr *fakeLogsReceiver) GetEntries() []loki.Entry {
lr.entriesMut.RLock()
defer lr.entriesMut.RUnlock()
return lr.entries
}
60 changes: 0 additions & 60 deletions internal/component/faro/receiver/test_utils.go

This file was deleted.

0 comments on commit 77997f0

Please sign in to comment.