Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable golangci-lint for pulsar #2121

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:

- name: golangci-lint
# TODO: Remove each example/module once it passes the golangci-lint
if: ${{ inputs.platform == 'ubuntu-latest' && inputs.go-version == '1.20.x' && !contains(fromJSON('["examples/cockroachdb", "examples/toxiproxy", "modules/compose", "modules/pulsar", "modules/redis"]'), inputs.project-directory) }}
if: ${{ inputs.platform == 'ubuntu-latest' && inputs.go-version == '1.20.x' && !contains(fromJSON('["examples/cockroachdb", "examples/toxiproxy", "modules/compose", "modules/redis"]'), inputs.project-directory) }}
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
Expand Down
22 changes: 11 additions & 11 deletions modules/pulsar/pulsar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ func TestPulsar(t *testing.T) {
ctx,
tt.opts...,
)
require.Nil(t, err)
require.NoError(t, err)
defer func() {
err := c.Terminate(ctx)
require.Nil(t, err)
require.NoError(t, err)
}()

// withLogConsumers {
Expand All @@ -120,12 +120,12 @@ func TestPulsar(t *testing.T) {
// getBrokerURL {
brokerURL, err := c.BrokerURL(ctx)
// }
require.Nil(t, err)
require.NoError(t, err)

// getAdminURL {
serviceURL, err := c.HTTPServiceURL(ctx)
// }
require.Nil(t, err)
require.NoError(t, err)

assert.True(t, strings.HasPrefix(brokerURL, "pulsar://"))
assert.True(t, strings.HasPrefix(serviceURL, "http://"))
Expand All @@ -135,7 +135,7 @@ func TestPulsar(t *testing.T) {
OperationTimeout: 30 * time.Second,
ConnectionTimeout: 30 * time.Second,
})
require.Nil(t, err)
require.NoError(t, err)
t.Cleanup(func() { pc.Close() })

subscriptionName := "pulsar-test"
Expand All @@ -145,7 +145,7 @@ func TestPulsar(t *testing.T) {
SubscriptionName: subscriptionName,
Type: pulsar.Exclusive,
})
require.Nil(t, err)
require.NoError(t, err)
t.Cleanup(func() { consumer.Close() })

msgChan := make(chan []byte)
Expand All @@ -166,12 +166,12 @@ func TestPulsar(t *testing.T) {
producer, err := pc.CreateProducer(pulsar.ProducerOptions{
Topic: "test-topic",
})
require.Nil(t, err)
require.NoError(t, err)

_, err = producer.Send(ctx, &pulsar.ProducerMessage{
Payload: []byte("hello world"),
})
require.Nil(t, err)
require.NoError(t, err)

ticker := time.NewTicker(1 * time.Minute)
select {
Expand All @@ -189,15 +189,15 @@ func TestPulsar(t *testing.T) {
}

resp, err := httpClient.Get(serviceURL + "/admin/v2/persistent/public/default/test-topic/stats")
require.Nil(t, err)
require.NoError(t, err)
defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
require.Nil(t, err)
require.NoError(t, err)

var stats map[string]interface{}
err = json.Unmarshal(body, &stats)
require.Nil(t, err)
require.NoError(t, err)

subscriptions := stats["subscriptions"]
require.NotNil(t, subscriptions)
Expand Down