Update on the Review Comments

1. Resolved review comments.
2. Resolved Go linting issues.
3. Increase coverage from 93 to 96 percentage for module.
This commit is contained in:
MohitKatare-protean
2025-03-27 12:24:17 +05:30
parent 2fa34759bc
commit be30b522b5
14 changed files with 291 additions and 102 deletions

View File

@@ -25,10 +25,10 @@ type Config struct {
Log log.Config `yaml:"log"`
PluginManager *plugin.ManagerConfig `yaml:"pluginManager"`
Modules []module.Config `yaml:"modules"`
HTTP httpConfig `yaml:"http"` // Nest http config
HTTP timeouts `yaml:"http"` // Nest http config
}
type httpConfig struct {
type timeouts struct {
Port string `yaml:"port"`
Timeout timeoutConfig `yaml:"timeout"`
}
@@ -44,7 +44,7 @@ var runFunc = run
func main() {
// Define and parse command-line flags.
flag.StringVar(&configPath, "config", "../../config/clientSideHandler-config.yaml", "Path to the configuration file")
flag.StringVar(&configPath, "config", "../../config/onix/adapter.yaml", "Path to the configuration file")
flag.Parse()
// Use custom log for initial setup messages.

View File

@@ -73,22 +73,6 @@ func (m *MockPluginManager) SchemaValidator(ctx context.Context, cfg *plugin.Con
return nil, nil
}
// testConfigContent defines a mock configuration used in tests.
const testConfigContent = `
appName: "TestApp"
http:
port: "8080"
timeout:
read: 5
write: 5
idle: 10
`
// initLogger is a mock function to initialize the logger.
var initLogger = func(cfg *Config) error {
return nil
}
// mockRun is a mock implementation of the `run` function, simulating a successful run.
func mockRun(ctx context.Context, configPath string) error {
return nil // Simulate a successful run
@@ -110,7 +94,9 @@ func TestMainFunction(t *testing.T) {
fs := flag.NewFlagSet("test", flag.ExitOnError)
fs.StringVar(&configPath, "config", "../../config/clientSideHandler-config.yaml", "Path to the configuration file")
fs.Parse(os.Args[1:])
if err := fs.Parse(os.Args[1:]); err != nil {
t.Fatalf("Failed to parse flags: %v", err)
}
main()
}
@@ -378,7 +364,7 @@ func TestNewServerSuccess(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
cfg := &Config{
Modules: tt.modules,
HTTP: httpConfig{
HTTP: timeouts{
Port: "8080",
Timeout: timeoutConfig{
Read: 5,
@@ -423,7 +409,7 @@ func TestNewServerFailure(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
cfg := &Config{
Modules: tt.modules,
HTTP: httpConfig{
HTTP: timeouts{
Port: "8080",
Timeout: timeoutConfig{
Read: 5,
@@ -455,7 +441,7 @@ func TestValidateConfigSuccess(t *testing.T) {
name: "Valid Config",
cfg: Config{
AppName: "TestApp",
HTTP: httpConfig{
HTTP: timeouts{
Port: "8080",
},
},
@@ -483,7 +469,7 @@ func TestValidateConfigFailure(t *testing.T) {
name: "Missing AppName",
cfg: Config{
AppName: "",
HTTP: httpConfig{
HTTP: timeouts{
Port: "8080",
},
},
@@ -493,7 +479,7 @@ func TestValidateConfigFailure(t *testing.T) {
name: "Missing Port",
cfg: Config{
AppName: "TestApp",
HTTP: httpConfig{
HTTP: timeouts{
Port: "",
},
},