-
Notifications
You must be signed in to change notification settings - Fork 408
Expand file tree
/
Copy pathconsumers_feature_create.go
More file actions
127 lines (111 loc) · 4.25 KB
/
Copy pathconsumers_feature_create.go
File metadata and controls
127 lines (111 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package tcp_test
import (
"context"
iggcon "github.com/apache/iggy/foreign/go/contracts"
ierror "github.com/apache/iggy/foreign/go/errors"
"github.com/onsi/ginkgo/v2"
)
var _ = ginkgo.Describe("CREATE CONSUMER GROUP:", func() {
prefix := "CreateConsumerGroup"
ginkgo.When("User is logged in", func() {
ginkgo.Context("and tries to create consumer group unique name and id", func() {
client := createAuthorizedConnection()
streamId, _ := successfullyCreateStream(prefix, client)
defer deleteStreamAfterTests(streamId, client)
topicId, _ := successfullyCreateTopic(streamId, client)
streamIdentifier, _ := iggcon.NewIdentifier(streamId)
topicIdentifier, _ := iggcon.NewIdentifier(topicId)
name := createRandomString(16)
group, err := client.CreateConsumerGroup(
context.Background(),
streamIdentifier,
topicIdentifier,
name,
)
itShouldNotReturnError(err)
itShouldSuccessfullyCreateConsumer(streamId, topicId, group.Id, name, client)
})
ginkgo.Context("and tries to create consumer group for a non existing stream", func() {
client := createAuthorizedConnection()
_, err := client.CreateConsumerGroup(
context.Background(),
randomU32Identifier(),
randomU32Identifier(),
createRandomString(16),
)
itShouldReturnSpecificError(err, ierror.ErrStreamIdNotFound)
})
ginkgo.Context("and tries to create consumer group for a non existing topic", func() {
client := createAuthorizedConnection()
streamId, _ := successfullyCreateStream(prefix, client)
defer deleteStreamAfterTests(streamId, client)
streamIdentifier, _ := iggcon.NewIdentifier(streamId)
_, err := client.CreateConsumerGroup(
context.Background(),
streamIdentifier,
randomU32Identifier(),
createRandomString(16),
)
itShouldReturnSpecificError(err, ierror.ErrTopicIdNotFound)
})
ginkgo.Context("and tries to create consumer group with duplicate group name", func() {
client := createAuthorizedConnection()
streamId, _ := successfullyCreateStream(prefix, client)
defer deleteStreamAfterTests(streamId, client)
topicId, _ := successfullyCreateTopic(streamId, client)
_, name := successfullyCreateConsumer(streamId, topicId, client)
streamIdentifier, _ := iggcon.NewIdentifier(streamId)
topicIdentifier, _ := iggcon.NewIdentifier(topicId)
_, err := client.CreateConsumerGroup(
context.Background(),
streamIdentifier,
topicIdentifier,
name,
)
itShouldReturnSpecificError(err, ierror.ErrConsumerGroupNameAlreadyExists)
})
ginkgo.Context("and tries to create group with name that's over 255 characters", func() {
client := createAuthorizedConnection()
streamId, _ := successfullyCreateStream(prefix, client)
defer deleteStreamAfterTests(streamId, client)
topicId, _ := successfullyCreateTopic(streamId, client)
streamIdentifier, _ := iggcon.NewIdentifier(streamId)
topicIdentifier, _ := iggcon.NewIdentifier(topicId)
_, err := client.CreateConsumerGroup(
context.Background(),
streamIdentifier,
topicIdentifier,
createRandomString(256),
)
itShouldReturnSpecificError(err, ierror.ErrInvalidConsumerGroupName)
})
})
ginkgo.When("User is not logged in", func() {
ginkgo.Context("and tries to create consumer group", func() {
client := createClient()
_, err := client.CreateConsumerGroup(
context.Background(),
randomU32Identifier(),
randomU32Identifier(),
createRandomString(16),
)
itShouldReturnUnauthenticatedError(err)
})
})
})