Skip to content

Commit

Permalink
added tests for workceptor.go
Browse files Browse the repository at this point in the history
  • Loading branch information
resoluteCoder committed Jan 16, 2024
1 parent 2bae5f3 commit 9de57bd
Show file tree
Hide file tree
Showing 3 changed files with 510 additions and 1 deletion.
139 changes: 139 additions & 0 deletions pkg/workceptor/mock_workceptor/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion pkg/workceptor/workceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"crypto/tls"
"fmt"
"io"
"io/fs"
"net"
"os"
"path"
"reflect"
Expand All @@ -34,6 +36,17 @@ type NetceptorForWorkceptor interface {
DialContext(ctx context.Context, node string, service string, tlscfg *tls.Config) (*netceptor.Conn, error) // create an interface for Conn
}

type ServerForWorkceptor interface {
AddControlFunc(name string, cType controlsvc.ControlCommandType) error
ConnectionListener(ctx context.Context, listener net.Listener)
RunControlSession(conn net.Conn)
RunControlSvc(ctx context.Context, service string, tlscfg *tls.Config, unixSocket string, unixSocketPermissions fs.FileMode, tcpListen string, tcptls *tls.Config) error
SetServerNet(n controlsvc.Neter)
SetServerTLS(t controlsvc.Tlser)
SetServerUtils(u controlsvc.Utiler)
SetupConnection(conn net.Conn)
}

// Workceptor is the main object that handles unit-of-work management.
type Workceptor struct {
ctx context.Context
Expand Down Expand Up @@ -97,7 +110,7 @@ func stdoutSize(unitdir string) int64 {
}

// RegisterWithControlService registers this workceptor instance with a control service instance.
func (w *Workceptor) RegisterWithControlService(cs *controlsvc.Server) error {
func (w *Workceptor) RegisterWithControlService(cs ServerForWorkceptor) error {
err := cs.AddControlFunc("work", &workceptorCommandType{
w: w,
})
Expand Down

0 comments on commit 9de57bd

Please sign in to comment.