Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
46
pkg/kafka/admin_test.go
Normal file
46
pkg/kafka/admin_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package kafka
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"fiskerinc.com/modules/kafka/mock"
|
||||
"fiskerinc.com/modules/testhelper"
|
||||
|
||||
"github.com/confluentinc/confluent-kafka-go/v2/kafka"
|
||||
)
|
||||
|
||||
func TestAdmin(t *testing.T) {
|
||||
a := mock.Admin{
|
||||
MockFunc: func(ctx context.Context, topics []kafka.TopicSpecification, options ...kafka.CreateTopicsAdminOption) ([]kafka.TopicResult, error) {
|
||||
return []kafka.TopicResult{{
|
||||
Topic: "test",
|
||||
Error: kafka.Error{},
|
||||
}}, nil
|
||||
},
|
||||
}
|
||||
|
||||
Admin = &a
|
||||
|
||||
err := EnsureTopicsExist([]string{"test"})
|
||||
if err != nil {
|
||||
t.Errorf(testhelper.TestErrorTemplate, "TestAdmin", nil, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminError(t *testing.T) {
|
||||
testError := errors.New("Test error being thrown")
|
||||
a := mock.Admin{
|
||||
MockFunc: func(ctx context.Context, topics []kafka.TopicSpecification, options ...kafka.CreateTopicsAdminOption) ([]kafka.TopicResult, error) {
|
||||
return []kafka.TopicResult{}, testError
|
||||
},
|
||||
}
|
||||
|
||||
Admin = &a
|
||||
|
||||
err := EnsureTopicsExist([]string{"test"})
|
||||
if err.Error() != testError.Error() {
|
||||
t.Errorf(testhelper.TestErrorTemplate, "TestAdmin", testError, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user