mirror of
https://github.com/go-micro/go-micro.git
synced 2025-11-29 21:47:44 +02:00
feat(CI): add linting and pretty test output (#2562)
This commit is contained in:
@@ -21,6 +21,8 @@ type testCase struct {
|
||||
func TestStream(t *testing.T) {
|
||||
tcs := []testCase{}
|
||||
|
||||
t.Parallel()
|
||||
|
||||
stream, err := NewStream()
|
||||
assert.Nilf(t, err, "NewStream should not return an error")
|
||||
assert.NotNilf(t, stream, "NewStream should return a stream object")
|
||||
@@ -28,6 +30,7 @@ func TestStream(t *testing.T) {
|
||||
|
||||
for _, tc := range tcs {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
runTestStream(t, tc.str)
|
||||
})
|
||||
}
|
||||
@@ -35,8 +38,11 @@ func TestStream(t *testing.T) {
|
||||
}
|
||||
|
||||
func runTestStream(t *testing.T, stream Stream) {
|
||||
t.Parallel()
|
||||
|
||||
// TestMissingTopic will test the topic validation on publish
|
||||
t.Run("TestMissingTopic", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := stream.Publish("", nil)
|
||||
assert.Equalf(t, err, ErrMissingTopic, "Publishing to a blank topic should return an error")
|
||||
})
|
||||
@@ -44,6 +50,7 @@ func runTestStream(t *testing.T, stream Stream) {
|
||||
// TestConsumeTopic will publish a message to the test topic. The subscriber will subscribe to the
|
||||
// same test topic.
|
||||
t.Run("TestConsumeTopic", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
payload := &testPayload{Message: "HelloWorld"}
|
||||
metadata := map[string]string{"foo": "bar"}
|
||||
|
||||
@@ -85,6 +92,8 @@ func runTestStream(t *testing.T, stream Stream) {
|
||||
// the message from the firehose topic with different queues. The second subscriber will be registered
|
||||
// after the message is published to test durability.
|
||||
t.Run("TestConsumeGroup", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
topic := uuid.New().String()
|
||||
payload := &testPayload{Message: "HelloWorld"}
|
||||
metadata := map[string]string{"foo": "bar"}
|
||||
@@ -150,6 +159,8 @@ func runTestStream(t *testing.T, stream Stream) {
|
||||
})
|
||||
|
||||
t.Run("AckingNacking", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ch, err := stream.Consume("foobarAck", WithAutoAck(false, 5*time.Second))
|
||||
assert.NoError(t, err, "Unexpected error subscribing")
|
||||
assert.NoError(t, stream.Publish("foobarAck", map[string]string{"foo": "message 1"}))
|
||||
@@ -171,6 +182,8 @@ func runTestStream(t *testing.T, stream Stream) {
|
||||
})
|
||||
|
||||
t.Run("Retries", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ch, err := stream.Consume("foobarRetries", WithAutoAck(false, 5*time.Second), WithRetryLimit(1))
|
||||
assert.NoError(t, err, "Unexpected error subscribing")
|
||||
assert.NoError(t, stream.Publish("foobarRetries", map[string]string{"foo": "message 1"}))
|
||||
@@ -186,10 +199,11 @@ func runTestStream(t *testing.T, stream Stream) {
|
||||
t.Fatalf("Unexpected event received")
|
||||
case <-time.After(7 * time.Second):
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
t.Run("InfiniteRetries", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ch, err := stream.Consume("foobarRetriesInf", WithAutoAck(false, 2*time.Second))
|
||||
assert.NoError(t, err, "Unexpected error subscribing")
|
||||
assert.NoError(t, stream.Publish("foobarRetriesInf", map[string]string{"foo": "message 1"}))
|
||||
@@ -212,10 +226,11 @@ func runTestStream(t *testing.T, stream Stream) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
t.Run("twoSubs", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ch1, err := stream.Consume("foobarTwoSubs1", WithAutoAck(false, 5*time.Second))
|
||||
assert.NoError(t, err, "Unexpected error subscribing to topic 1")
|
||||
ch2, err := stream.Consume("foobarTwoSubs2", WithAutoAck(false, 5*time.Second))
|
||||
|
||||
Reference in New Issue
Block a user