Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed May 4, 2023
1 parent 7087ab8 commit c59aa5a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 36 deletions.
58 changes: 29 additions & 29 deletions clienter_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions slackdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type Session struct {
// WorkspaceInfo is an type alias for [slack.AuthTestResponse].
type WorkspaceInfo = slack.AuthTestResponse

type streamer interface {
// Slacker is the interface with some functions of slack.Client.
type Slacker interface {
AuthTestContext(context.Context) (response *slack.AuthTestResponse, err error)
GetConversationInfoContext(ctx context.Context, input *slack.GetConversationInfoInput) (*slack.Channel, error)
GetConversationHistoryContext(ctx context.Context, params *slack.GetConversationHistoryParameters) (*slack.GetConversationHistoryResponse, error)
Expand All @@ -49,7 +50,7 @@ type streamer interface {
// clienter is the interface with some functions of slack.Client with the sole
// purpose of mocking in tests (see client_mock.go)
type clienter interface {
streamer
Slacker
GetFile(downloadURL string, writer io.Writer) error
GetUsersContext(ctx context.Context, options ...slack.GetUsersOption) ([]slack.User, error)
GetEmojiContext(ctx context.Context) (map[string]string, error)
Expand Down Expand Up @@ -199,5 +200,5 @@ func (s *Session) Info() *WorkspaceInfo {

// Stream streams the channel, calling proc functions for each chunk.
func (s *Session) Stream(opts ...StreamOption) *Stream {
return newChannelStream(s.client, &s.cfg.limits, opts...)
return NewStream(s.client, &s.cfg.limits, opts...)
}
6 changes: 4 additions & 2 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
// use.
type Stream struct {
oldest, latest time.Time
client streamer
client Slacker
limits rateLimits
chanCache *chanCache
}
Expand Down Expand Up @@ -115,7 +115,9 @@ func OptLatest(t time.Time) StreamOption {
}
}

func newChannelStream(cl streamer, l *Limits, opts ...StreamOption) *Stream {
// NewStream creates a new Stream instance that allows to stream different
// slack entities.
func NewStream(cl Slacker, l *Limits, opts ...StreamOption) *Stream {
cs := &Stream{
client: cl,
limits: limits(l),
Expand Down
4 changes: 2 additions & 2 deletions stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestChannelStream(t *testing.T) {
rec := chunk.NewRecorder(f)
defer rec.Close()

cs := newChannelStream(sd, &DefLimits)
cs := NewStream(sd, &DefLimits)
if err := cs.SyncConversations(context.Background(), rec, testConversation); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestRecorderStream(t *testing.T) {
defer rec.Close()

rgnStream := trace.StartRegion(ctx, "Stream")
cs := newChannelStream(sd, &NoLimits)
cs := NewStream(sd, &NoLimits)
if err := cs.SyncConversations(ctx, rec, fixtures.ChunkFileChannelID); err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit c59aa5a

Please sign in to comment.