MCPcopy Create free account
hub / github.com/anchordotdev/cli / TestConfigLoadTOML

Function TestConfigLoadTOML

config_test.go:114–181  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

112}
113
114func TestConfigLoadTOML(t *testing.T) {
115 tests := []struct {
116 name string
117
118 toml string
119
120 cfgFn func(*Config)
121 }{
122 {
123 name: "defaults-empty",
124
125 toml: "",
126
127 cfgFn: func(cfg *Config) {},
128 },
129 {
130 name: "service-acme-example",
131
132 toml: heredoc.Doc(`
133 [lcl-host]
134 realm-apid = "localhost"
135
136 [org]
137 apid = "test-org"
138
139 [service]
140 apid = "test-service"
141 category = "ruby"
142 cert-style = "acme"
143 `),
144
145 cfgFn: func(cfg *Config) {
146 cfg.Lcl.RealmAPID = "localhost"
147 cfg.Org.APID = "test-org"
148 cfg.Service.APID = "test-service"
149 cfg.Service.Category = "ruby"
150 cfg.Service.CertStyle = "acme"
151 },
152 },
153 }
154
155 for _, test := range tests {
156 t.Run(test.name, func(t *testing.T) {
157 fs := fstest.MapFS{
158 "anchor.toml": &fstest.MapFile{
159 Data: []byte(test.toml),
160 },
161 }
162
163 cfg := defaultConfig()
164 if err := cfg.loadTOML(fs); err != nil {
165 t.Fatal(err)
166 }
167
168 expected := defaultConfig()
169 test.cfgFn(expected)
170
171 if diff := deep.Equal(expected, cfg.Via.TOML); diff != nil {

Callers

nothing calls this directly

Calls 4

defaultConfigFunction · 0.85
loadTOMLMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected