@@ -31,6 +31,10 @@ func ptr(n int) *int {
3131 return & n
3232}
3333
34+ func boolPtr (b bool ) * bool {
35+ return & b
36+ }
37+
3438func TestSetTopicAutoCreation (t * testing.T ) {
3539 config := & config.Config {}
3640 admin , err := New (config )
@@ -47,7 +51,7 @@ func TestSetTopicAutoCreation(t *testing.T) {
4751 name : "Set partitioned type topic auto creation" ,
4852 namespace : "public/default" ,
4953 config : utils.TopicAutoCreationConfig {
50- Allow : true ,
54+ Allow : boolPtr ( true ) ,
5155 Type : utils .Partitioned ,
5256 Partitions : ptr (3 ),
5357 },
@@ -57,7 +61,7 @@ func TestSetTopicAutoCreation(t *testing.T) {
5761 name : "Set partitioned type topic auto creation without partitions" ,
5862 namespace : "public/default" ,
5963 config : utils.TopicAutoCreationConfig {
60- Allow : true ,
64+ Allow : boolPtr ( true ) ,
6165 Type : utils .Partitioned ,
6266 },
6367 errReason : "Invalid configuration for autoTopicCreationOverride. the detail is [defaultNumPartitions] " +
@@ -67,7 +71,7 @@ func TestSetTopicAutoCreation(t *testing.T) {
6771 name : "Set partitioned type topic auto creation with partitions < 1" ,
6872 namespace : "public/default" ,
6973 config : utils.TopicAutoCreationConfig {
70- Allow : true ,
74+ Allow : boolPtr ( true ) ,
7175 Type : utils .Partitioned ,
7276 Partitions : ptr (- 1 ),
7377 },
@@ -78,7 +82,7 @@ func TestSetTopicAutoCreation(t *testing.T) {
7882 name : "Set non-partitioned type topic auto creation" ,
7983 namespace : "public/default" ,
8084 config : utils.TopicAutoCreationConfig {
81- Allow : true ,
85+ Allow : boolPtr ( true ) ,
8286 Type : utils .NonPartitioned ,
8387 },
8488 errReason : "" ,
@@ -87,7 +91,7 @@ func TestSetTopicAutoCreation(t *testing.T) {
8791 name : "Set non-partitioned type topic auto creation with partitions" ,
8892 namespace : "public/default" ,
8993 config : utils.TopicAutoCreationConfig {
90- Allow : true ,
94+ Allow : boolPtr ( true ) ,
9195 Type : utils .NonPartitioned ,
9296 Partitions : ptr (3 ),
9397 },
@@ -98,15 +102,15 @@ func TestSetTopicAutoCreation(t *testing.T) {
98102 name : "Disable topic auto creation" ,
99103 namespace : "public/default" ,
100104 config : utils.TopicAutoCreationConfig {
101- Allow : false ,
105+ Allow : boolPtr ( false ) ,
102106 },
103107 errReason : "" ,
104108 },
105109 {
106110 name : "Set topic auto creation on a non-exist namespace" ,
107111 namespace : "public/nonexist" ,
108112 config : utils.TopicAutoCreationConfig {
109- Allow : true ,
113+ Allow : boolPtr ( true ) ,
110114 Type : utils .NonPartitioned ,
111115 },
112116 errReason : "Namespace does not exist" ,
@@ -115,7 +119,7 @@ func TestSetTopicAutoCreation(t *testing.T) {
115119 name : "Set topic auto creation on a non-exist tenant" ,
116120 namespace : "non-exist/default" ,
117121 config : utils.TopicAutoCreationConfig {
118- Allow : true ,
122+ Allow : boolPtr ( true ) ,
119123 Type : utils .NonPartitioned ,
120124 },
121125 errReason : "Tenant does not exist" ,
@@ -149,14 +153,14 @@ func TestGetTopicAutoCreation(t *testing.T) {
149153
150154 // set the topic auto creation config and get it
151155 err = admin .Namespaces ().SetTopicAutoCreation (* namespace , utils.TopicAutoCreationConfig {
152- Allow : true ,
156+ Allow : boolPtr ( true ) ,
153157 Type : utils .NonPartitioned ,
154158 })
155159 assert .Equal (t , nil , err )
156160 topicAutoCreation , err := admin .Namespaces ().GetTopicAutoCreation (* namespace )
157161 assert .Equal (t , nil , err )
158162 expected := utils.TopicAutoCreationConfig {
159- Allow : true ,
163+ Allow : boolPtr ( true ) ,
160164 Type : utils .NonPartitioned ,
161165 }
162166 assert .Equal (t , expected , * topicAutoCreation )
@@ -168,7 +172,7 @@ func TestGetTopicAutoCreation(t *testing.T) {
168172 topicAutoCreation , err = admin .Namespaces ().GetTopicAutoCreation (* namespace )
169173 assert .Equal (t , nil , err )
170174 expected = utils.TopicAutoCreationConfig {
171- Allow : false ,
175+ Allow : boolPtr ( false ) ,
172176 Type : "" ,
173177 }
174178 assert .Equal (t , expected , * topicAutoCreation )
0 commit comments