• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

matzefriedrich / parsley / 25524847756

07 May 2026 10:09PM UTC coverage: 79.58% (-0.2%) from 79.735%
25524847756

Pull #83

github

matzefriedrich
Handle activation error in application context initialization
Pull Request #83: Handle activation error in application context initialization

2 of 6 new or added lines in 1 file covered. (33.33%)

1 existing line in 1 file now uncovered.

2046 of 2571 relevant lines covered (79.58%)

31.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.74
/pkg/bootstrap/application.go
1
package bootstrap
2

3
import (
4
        "context"
5
        "errors"
6

7
        "github.com/matzefriedrich/parsley/internal/core"
8
        "github.com/matzefriedrich/parsley/pkg/registration"
9
        "github.com/matzefriedrich/parsley/pkg/resolving"
10
        "github.com/matzefriedrich/parsley/pkg/types"
11
)
12

13
type infrastructure struct {
14
        registry types.ServiceRegistry
15
        resolver types.Resolver
16
        app      Application
17
}
18

19
const (
20
        ErrorCannotRegisterAppFactory = "cannot register application factory"
21
)
22

23
// ErrCannotRegisterAppFactory is returned when the application factory cannot be registered, indicating an issue with the bootstrap process.
24
var (
25
        ErrCannotRegisterAppFactory = errors.New(ErrorCannotRegisterAppFactory)
26
)
27

28
// RunParsleyApplication initializes and runs the Parsley application lifecycle.
29
// It registers the application factory, configures additional modules, resolves the main application instance, and invokes its Run method.
30
func RunParsleyApplication(cxt context.Context, appFactoryFunc any, configure ...types.ModuleFunc) error {
1✔
31

1✔
32
        registry := registration.NewServiceRegistry()
1✔
33
        registerErr := registry.Register(appFactoryFunc, types.LifetimeSingleton)
1✔
34
        if registerErr != nil {
1✔
35
                bootstrapErr := &types.ParsleyError{Msg: ErrorCannotRegisterAppFactory}
×
36
                types.WithCause(registerErr)(bootstrapErr)
×
37
                return bootstrapErr
×
38
        }
×
39
        for _, m := range configure {
2✔
40
                _ = m(registry)
1✔
41
        }
1✔
42

×
43
        resolver := resolving.NewResolver(registry)
1✔
44
        ctx := resolving.NewScopedContext(cxt)
1✔
45
        app, appErr := resolving.ResolveRequiredService[Application](ctx, resolver)
1✔
46
        if appErr != nil {
1✔
NEW
47
                activationErr := &types.ParsleyError{Msg: "failed to activate application"}
×
NEW
48
                types.WithCause(appErr)(activationErr)
×
NEW
49
                return activationErr
×
NEW
50
        }
×
UNCOV
51

×
52
        parsley := infrastructure{
1✔
53
                registry: registry,
1✔
54
                resolver: resolver,
1✔
55
                app:      app,
1✔
56
        }
1✔
57

1✔
58
        appContext := context.WithValue(ctx, core.ContextKey("__parsley-infrastructure"), parsley)
1✔
59

1✔
60
        return app.Run(appContext)
1✔
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc