generated from xmidt-org/.go-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovide_test.go
85 lines (74 loc) · 1.38 KB
/
provide_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// SPDX-FileCopyrightText: 2025 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package praetor
import (
"testing"
"github.com/hashicorp/consul/api"
"github.com/stretchr/testify/suite"
"go.uber.org/fx"
"go.uber.org/fx/fxtest"
)
type ProvideSuite struct {
suite.Suite
}
func (suite *ProvideSuite) TestProvide() {
var (
client *api.Client
agent *api.Agent
catalog *api.Catalog
health *api.Health
app = fxtest.New(
suite.T(),
fx.Supply(api.Config{}),
Provide(),
fx.Populate(
&client,
&agent,
&catalog,
&health,
),
)
)
suite.NoError(app.Err())
suite.NotNil(client)
suite.NotNil(agent)
suite.NotNil(catalog)
suite.NotNil(health)
}
func (suite *ProvideSuite) TestProvideConfig() {
var (
config api.Config
client *api.Client
agent *api.Agent
catalog *api.Catalog
health *api.Health
app = fxtest.New(
suite.T(),
fx.Supply(
Config{
Scheme: "http",
Address: "foobar:8080",
},
),
Provide(),
ProvideConfig(),
fx.Populate(
&config,
&client,
&agent,
&catalog,
&health,
),
)
)
suite.NoError(app.Err())
suite.Equal("http", config.Scheme)
suite.Equal("foobar:8080", config.Address)
suite.NotNil(client)
suite.NotNil(agent)
suite.NotNil(catalog)
suite.NotNil(health)
}
func TestProvide(t *testing.T) {
suite.Run(t, new(ProvideSuite))
}