fix: shared renamed to pkg, formatting changes
This commit is contained in:
@@ -7,10 +7,10 @@ type Publisher interface {
|
|||||||
// Publish sends a message (as a byte slice) using the underlying messaging system.
|
// Publish sends a message (as a byte slice) using the underlying messaging system.
|
||||||
Publish(ctx context.Context, msg []byte) error
|
Publish(ctx context.Context, msg []byte) error
|
||||||
|
|
||||||
Close() error // Important for releasing resources
|
Close() error // Important for releasing resources.
|
||||||
}
|
}
|
||||||
|
|
||||||
type PublisherProvider interface {
|
type PublisherProvider interface {
|
||||||
// New initializes a new publisher instance with the given configuration
|
// New initializes a new publisher instance with the given configuration.
|
||||||
New(ctx context.Context, config map[string]string) (Publisher, error)
|
New(ctx context.Context, config map[string]string) (Publisher, error)
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/beckn/beckn-onix/shared/plugin/definition"
|
"github.com/beckn/beckn-onix/pkg/plugin/definition"
|
||||||
"github.com/beckn/beckn-onix/shared/plugin/implementation/publisher"
|
"github.com/beckn/beckn-onix/pkg/plugin/implementation/publisher"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Returns error if required fields are missing.
|
// Returns error if required fields are missing.
|
||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/beckn/beckn-onix/shared/plugin/definition"
|
"github.com/beckn/beckn-onix/pkg/plugin/definition"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockPublisher is a mock implementation of the definition.Publisher interface for testing.
|
// MockPublisher is a mock implementation of the definition.Publisher interface for testing.
|
||||||
@@ -4,22 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"cloud.google.com/go/pubsub"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Helper to create a test publisher directly
|
// TestValidate tests the validate function.
|
||||||
func createTestPublisher() *Publisher {
|
|
||||||
client, _ := pubsub.NewClient(context.Background(), "test-project")
|
|
||||||
topic := client.Topic("test-topic")
|
|
||||||
return &Publisher{
|
|
||||||
client: client,
|
|
||||||
topic: topic,
|
|
||||||
config: &Config{ProjectID: "test-project", TopicID: "test-topic"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestValidate tests the validate function
|
|
||||||
func TestValidate(t *testing.T) {
|
func TestValidate(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -68,8 +55,8 @@ func TestValidate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestNew tests the New function with validation errors only
|
// TestNew tests the New function with validation errors only.
|
||||||
// We can't easily test the pubsub client creation parts without complex mocks
|
// We can't easily test the pubsub client creation parts without complex mocks.
|
||||||
func TestNew(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -109,15 +96,3 @@ func TestNew(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPublish tests the behavior of the Publisher.Publish method
|
|
||||||
// Since we can't easily mock the pubsub client and topic, we'll skip the actual test
|
|
||||||
func TestPublish(t *testing.T) {
|
|
||||||
t.Skip("Requires real pubsub client or complex mocking")
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestClose tests the behavior of the Publisher.Close method
|
|
||||||
// Since we can't easily mock the pubsub client, we'll skip the actual test
|
|
||||||
func TestClose(t *testing.T) {
|
|
||||||
t.Skip("Requires real pubsub client or complex mocking")
|
|
||||||
}
|
|
||||||
@@ -4,17 +4,16 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/beckn/beckn-onix/shared/plugin/definition"
|
"github.com/beckn/beckn-onix/pkg/plugin/definition"
|
||||||
|
|
||||||
plugin "github.com/beckn/beckn-onix/shared/plugin/definition"
|
verifier "github.com/beckn/beckn-onix/pkg/plugin/implementation/signVerifier"
|
||||||
verifier "github.com/beckn/beckn-onix/shared/plugin/implementation/signVerifier"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// VerifierProvider provides instances of Verifier.
|
// VerifierProvider provides instances of Verifier.
|
||||||
type VerifierProvider struct{}
|
type VerifierProvider struct{}
|
||||||
|
|
||||||
// New initializes a new Verifier instance.
|
// New initializes a new Verifier instance.
|
||||||
func (vp VerifierProvider) New(ctx context.Context, config map[string]string) (plugin.Verifier, func() error, error) {
|
func (vp VerifierProvider) New(ctx context.Context, config map[string]string) (definition.Verifier, func() error, error) {
|
||||||
if ctx == nil {
|
if ctx == nil {
|
||||||
return nil, nil, errors.New("context cannot be nil")
|
return nil, nil, errors.New("context cannot be nil")
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/beckn/beckn-onix/shared/plugin/definition"
|
"github.com/beckn/beckn-onix/pkg/plugin/definition"
|
||||||
"github.com/beckn/beckn-onix/shared/plugin/implementation/signer"
|
"github.com/beckn/beckn-onix/pkg/plugin/implementation/signer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SignerProvider implements the definition.SignerProvider interface.
|
// SignerProvider implements the definition.SignerProvider interface.
|
||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"plugin"
|
"plugin"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/beckn/beckn-onix/shared/plugin/definition"
|
"github.com/beckn/beckn-onix/pkg/plugin/definition"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config represents the plugin manager configuration.
|
// Config represents the plugin manager configuration.
|
||||||
Reference in New Issue
Block a user