Skip to content

Commit

Permalink
exclude tests
Browse files Browse the repository at this point in the history
  • Loading branch information
korovindenis committed Apr 26, 2024
1 parent 4cd685d commit 7b62c11
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 86 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ issues:
- unused
- unparam
- gocritic
- forcetypeassert
- path: topic/topicreader/reader_example_test.go
linters:
- staticcheck
Expand Down
2 changes: 0 additions & 2 deletions internal/credentials/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,7 @@ func TestJWTTokenSource(t *testing.T) {
require.NoError(t, parsedToken.Claims.Valid())
require.Equal(t, "test_issuer", claims.Issuer)
require.Equal(t, "test_audience", claims.Audience[0])
//nolint:forcetypeassert
require.Equal(t, "key_id", parsedToken.Header["kid"].(string))
//nolint:forcetypeassert
require.Equal(t, "RS256", parsedToken.Header["alg"].(string))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package rawtopicwriter

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -73,14 +72,7 @@ func TestSendWriteRequest(t *testing.T) {
}

getWriteRequest := func(req *Ydb_Topic.StreamWriteMessage_FromClient) *Ydb_Topic.StreamWriteMessage_WriteRequest {
//nolint:protogetter
res, ok := req.ClientMessage.(*Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest)
if !ok {
panic(fmt.Sprintf(`unsupported type conversion from %T to
*Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest`, res))
}

return res.WriteRequest
return req.GetClientMessage().(*Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest).WriteRequest
}

sendCounter := 0
Expand Down
5 changes: 1 addition & 4 deletions internal/table/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,7 @@ func (s *StubBuilder) createSession(ctx context.Context) (session *session, err
func (c *Client) debug() {
fmt.Print("head ")
for el := c.idle.Front(); el != nil; el = el.Next() {
s, ok := el.Value.(*session)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *session", s))
}
s := el.Value.(*session)
x := c.index[s]
fmt.Printf("<-> %s(%d) ", s.ID(), x.touched.Unix())
}
Expand Down
6 changes: 1 addition & 5 deletions internal/table/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,7 @@ func TestRetryerSessionClosing(t *testing.T) {
config.New(),
func(ctx context.Context, s table.Session) error {
sessions = append(sessions, s)
val, ok := s.(*session)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *session", val))
}
val.SetStatus(table.SessionClosing)
s.(*session).SetStatus(table.SessionClosing)

return nil
},
Expand Down
8 changes: 1 addition & 7 deletions internal/topic/topicreaderinternal/batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package topicreaderinternal
import (
"context"
"errors"
"fmt"
"sync/atomic"
"testing"
"time"
Expand Down Expand Up @@ -340,15 +339,10 @@ func TestBatcherConcurency(t *testing.T) {
for i := 0; i < count; i++ {
res, err := b.Pop(ctx, batcherGetOptions{MinCount: 1})
require.NoError(tb, err)

val, ok := res.RawMessage.(*rawtopicreader.StartPartitionSessionRequest)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *rawtopicreader.StartPartitionSessionRequest", val))
}
require.Equal(
tb,
rawtopicreader.NewOffset(int64(i)),
val.CommittedOffset,
res.RawMessage.(*rawtopicreader.StartPartitionSessionRequest).CommittedOffset,
)
}
})
Expand Down
17 changes: 3 additions & 14 deletions internal/topic/topicreaderinternal/committer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package topicreaderinternal
import (
"context"
"errors"
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -232,11 +231,7 @@ func TestCommitterBuffer(t *testing.T) {
c.clock = clock
c.BufferTimeLagTrigger = time.Second
c.send = func(msg rawtopicreader.ClientMessage) error {
commitMess, ok := msg.(*rawtopicreader.CommitOffsetRequest)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *rawtopicreader.CommitOffsetRequest", commitMess))
}

commitMess := msg.(*rawtopicreader.CommitOffsetRequest)
require.Len(t, commitMess.CommitOffsets, 2)
close(sendCalled)

Expand Down Expand Up @@ -269,10 +264,7 @@ func TestCommitterBuffer(t *testing.T) {
c.BufferTimeLagTrigger = time.Second // for prevent send
c.BufferCountTrigger = 2
c.send = func(msg rawtopicreader.ClientMessage) error {
commitMess, ok := msg.(*rawtopicreader.CommitOffsetRequest)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *rawtopicreader.CommitOffsetRequest", commitMess))
}
commitMess := msg.(*rawtopicreader.CommitOffsetRequest)
require.Len(t, commitMess.CommitOffsets, 4)
close(sendCalled)

Expand Down Expand Up @@ -307,10 +299,7 @@ func TestCommitterBuffer(t *testing.T) {
c.BufferTimeLagTrigger = time.Second // for prevent send
c.BufferCountTrigger = 4
c.send = func(msg rawtopicreader.ClientMessage) error {
commitMess, ok := msg.(*rawtopicreader.CommitOffsetRequest)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *rawtopicreader.CommitOffsetRequest", commitMess))
}
commitMess := msg.(*rawtopicreader.CommitOffsetRequest)
require.Len(t, commitMess.CommitOffsets, 4)
close(sendCalled)

Expand Down
9 changes: 2 additions & 7 deletions internal/topic/topicwriterinternal/writer_grpc_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,8 @@ func (t *topicWriterOperationUnavailable) StreamWrite(server Ydb_Topic_V1.TopicS
return errors.New("failed to read messages block")
}

val, ok := messagesMsg.GetClientMessage().(*Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest)
if !ok {
panic(fmt.Sprintf(`unsupported type conversion from %T
to *Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest`, val))
}

if len(val.WriteRequest.GetMessages()) == 0 {
if len(messagesMsg.GetClientMessage().(*Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest).
WriteRequest.GetMessages()) == 0 {
return errors.New("received zero messages block")
}

Expand Down
15 changes: 3 additions & 12 deletions internal/topic/topicwriterinternal/writer_reconnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ func TestWriterImpl_WriteCodecs(t *testing.T) {

messReceived := make(chan rawtopiccommon.Codec, 2)
e.stream.EXPECT().Send(gomock.Any()).Do(func(message rawtopicwriter.ClientMessage) {
writeReq, ok := message.(*rawtopicwriter.WriteRequest)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *rawtopicwriter.WriteRequest", writeReq))
}
writeReq := message.(*rawtopicwriter.WriteRequest)
messReceived <- writeReq.Codec
})

Expand Down Expand Up @@ -219,10 +216,7 @@ func TestWriterImpl_WriteCodecs(t *testing.T) {

messReceived := make(chan rawtopiccommon.Codec, 2)
e.stream.EXPECT().Send(gomock.Any()).Do(func(message rawtopicwriter.ClientMessage) {
writeReq, ok := message.(*rawtopicwriter.WriteRequest)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *rawtopicreader.WriteRequest", writeReq))
}
writeReq := message.(*rawtopicwriter.WriteRequest)
messReceived <- writeReq.Codec
})

Expand All @@ -247,10 +241,7 @@ func TestWriterImpl_WriteCodecs(t *testing.T) {

messReceived := make(chan rawtopiccommon.Codec, 2)
e.stream.EXPECT().Send(gomock.Any()).Do(func(message rawtopicwriter.ClientMessage) {
writeReq, ok := message.(*rawtopicwriter.WriteRequest)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *rawtopicwriter.WriteRequest", writeReq))
}
writeReq := message.(*rawtopicwriter.WriteRequest)
messReceived <- writeReq.Codec
}).Times(codecMeasureIntervalBatches * 2)

Expand Down
7 changes: 1 addition & 6 deletions internal/xerrors/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package xerrors

import (
"context"
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -51,11 +50,7 @@ func TestUnwrapJoined(t *testing.T) {

var joined error = Join(err1, err2)

unwrappable, ok := joined.(interface{ Unwrap() []error }) //nolint:errorlint
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to interface{ Unwrap() []error }", unwrappable))
}

unwrappable := joined.(interface{ Unwrap() []error }) //nolint:errorlint
inners := unwrappable.Unwrap()
assert.Contains(t, inners, err1)
assert.Contains(t, inners, err2)
Expand Down
6 changes: 1 addition & 5 deletions internal/xtest/call_method_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package xtest

import (
"bytes"
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -12,10 +11,7 @@ func TestCallMethod(t *testing.T) {
object := bytes.NewBuffer(nil)

result := CallMethod(object, "WriteString", "Hello world!")
n, ok := result[0].(int)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to int", n))
}
n := result[0].(int)
err := result[1]

require.Equal(t, 12, n)
Expand Down
18 changes: 3 additions & 15 deletions testutil/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package testutil

import (
"errors"
"fmt"
"testing"

"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
Expand All @@ -22,11 +21,7 @@ func TestUnwrapOptionalValue(t *testing.T) {
if typeID != Ydb.Type_UTF8 {
t.Errorf("Types are different: expected %d, actual %d", Ydb.Type_UTF8, typeID)
}
textValue, ok := val.GetValue().GetValue().(*Ydb.Value_TextValue)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *Ydb.Value_TextValue", textValue))
}

textValue := val.GetValue().GetValue().(*Ydb.Value_TextValue)
text := textValue.TextValue
if text != "a" {
t.Errorf("Values are different: expected %q, actual %q", "a", text)
Expand All @@ -42,10 +37,7 @@ func TestUnwrapPrimitiveValue(t *testing.T) {
if typeID != Ydb.Type_UTF8 {
t.Errorf("Types are different: expected %d, actual %d", Ydb.Type_UTF8, typeID)
}
textValue, ok := val.GetValue().GetValue().(*Ydb.Value_TextValue)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *Ydb.Value_TextValue", textValue))
}
textValue := val.GetValue().GetValue().(*Ydb.Value_TextValue)
text := textValue.TextValue
if text != "a" {
t.Errorf("Values are different: expected %q, actual %q", "a", text)
Expand All @@ -61,11 +53,7 @@ func TestUnwrapNullValue(t *testing.T) {
if typeID != Ydb.Type_UTF8 {
t.Errorf("Types are different: expected %d, actual %d", Ydb.Type_UTF8, typeID)
}

nullFlagValue, ok := val.GetValue().GetValue().(*Ydb.Value_NullFlagValue)
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *Ydb.Value_NullFlagValue", nullFlagValue))
}
nullFlagValue := val.GetValue().GetValue().(*Ydb.Value_NullFlagValue)
if nullFlagValue.NullFlagValue != structpb.NullValue_NULL_VALUE {
t.Errorf("Values are different: expected %d, actual %d", structpb.NullValue_NULL_VALUE, nullFlagValue.NullFlagValue)
}
Expand Down

0 comments on commit 7b62c11

Please sign in to comment.