MCPcopy Create free account
hub / github.com/github/gh-aw / TestCheckSecretsAvailability

Function TestCheckSecretsAvailability

pkg/cli/secrets_test.go:156–234  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func TestCheckSecretsAvailability(t *testing.T) {
157 tests := []struct {
158 name string
159 secrets []SecretInfo
160 envVars map[string]string
161 useActions bool
162 expectSource map[string]string // Map of secret name to expected source
163 }{
164 {
165 name: "secret in environment",
166 secrets: []SecretInfo{
167 {Name: "TEST_SECRET", EnvKey: "TEST_SECRET"},
168 },
169 envVars: map[string]string{
170 "TEST_SECRET": "test-value",
171 },
172 useActions: false,
173 expectSource: map[string]string{
174 "TEST_SECRET": "env",
175 },
176 },
177 {
178 name: "secret not found",
179 secrets: []SecretInfo{
180 {Name: "MISSING_SECRET", EnvKey: "MISSING_SECRET"},
181 },
182 envVars: map[string]string{},
183 useActions: false,
184 expectSource: map[string]string{
185 "MISSING_SECRET": "",
186 },
187 },
188 {
189 name: "multiple secrets mixed availability",
190 secrets: []SecretInfo{
191 {Name: "AVAILABLE_SECRET", EnvKey: "AVAILABLE_SECRET"},
192 {Name: "MISSING_SECRET", EnvKey: "MISSING_SECRET"},
193 },
194 envVars: map[string]string{
195 "AVAILABLE_SECRET": "value",
196 },
197 useActions: false,
198 expectSource: map[string]string{
199 "AVAILABLE_SECRET": "env",
200 "MISSING_SECRET": "",
201 },
202 },
203 }
204
205 for _, tt := range tests {
206 t.Run(tt.name, func(t *testing.T) {
207 // Set up environment variables
208 for key, value := range tt.envVars {
209 t.Setenv(key, value)
210 }
211
212 result := checkSecretsAvailability(tt.secrets, tt.useActions)
213

Callers

nothing calls this directly

Calls 4

checkSecretsAvailabilityFunction · 0.85
SetenvMethod · 0.80
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected