MCPcopy Create free account
hub / github.com/openclaw/gogcli / assertResolveKeyringBackendConfig

Function assertResolveKeyringBackendConfig

internal/secrets/store_test.go:247–278  ·  view source on GitHub ↗
(t *testing.T, envValue, wantValue, wantSource string)

Source from the content-addressed store, hash-verified

245}
246
247func assertResolveKeyringBackendConfig(t *testing.T, envValue, wantValue, wantSource string) {
248 t.Helper()
249 home := t.TempDir()
250 t.Setenv("HOME", home)
251 t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, "xdg-config"))
252 t.Setenv("GOG_KEYRING_BACKEND", envValue)
253
254 layout := testSystemLayout(t, config.PathKindConfig)
255 store := config.NewConfigStore(layout)
256 path := store.Path()
257
258 if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
259 t.Fatalf("mkdir: %v", err)
260 }
261
262 if err := os.WriteFile(path, []byte(`{ keyring_backend: "file" }`), 0o600); err != nil {
263 t.Fatalf("write config: %v", err)
264 }
265
266 info, err := ResolveKeyringBackendInfoWithOptions(systemTestOpenOptions(layout, store))
267 if err != nil {
268 t.Fatalf("ResolveKeyringBackendInfo: %v", err)
269 }
270
271 if info.Value != wantValue {
272 t.Fatalf("expected %s, got %q", wantValue, info.Value)
273 }
274
275 if info.Source != wantSource {
276 t.Fatalf("expected source %s, got %q", wantSource, info.Source)
277 }
278}
279
280func TestResolveKeyringBackendInfoUsesInjectedStore(t *testing.T) {
281 t.Setenv("GOG_KEYRING_BACKEND", "")

Calls 6

PathMethod · 0.95
NewConfigStoreFunction · 0.92
systemTestOpenOptionsFunction · 0.85
testSystemLayoutFunction · 0.70
DirMethod · 0.45

Tested by

no test coverage detected