MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / TestStore_Set_AddAndReplace

Function TestStore_Set_AddAndReplace

internal/cli/credentials_test.go:233–252  ·  view source on GitHub ↗

TestStore_Set_AddAndReplace — Set adds a new entry on first call, replaces it on a second call with the same key. Mirrors the URL into the value's ServerURL field for consumer consistency.

(t *testing.T)

Source from the content-addressed store, hash-verified

231// replaces it on a second call with the same key. Mirrors the URL into
232// the value's ServerURL field for consumer consistency.
233func TestStore_Set_AddAndReplace(t *testing.T) {
234 store := newEmptyStore()
235 store.Set("http://x:7777", &Credentials{Token: "first", Email: "a@a"})
236 store.Set("http://x:7777", &Credentials{Token: "second", Email: "b@b"})
237
238 got := store.Get("http://x:7777")
239 if got == nil {
240 t.Fatal("Get returned nil after Set")
241 }
242 if got.Token != "second" {
243 t.Errorf("token = %q, want second (replace failed)", got.Token)
244 }
245 if got.Email != "b@b" {
246 t.Errorf("email = %q, want b@b", got.Email)
247 }
248 // Set must mirror the URL into the value's ServerURL field.
249 if got.ServerURL != "http://x:7777" {
250 t.Errorf("ServerURL on stored value = %q, want http://x:7777", got.ServerURL)
251 }
252}
253
254// TestStore_Delete_KeepsSiblings — Delete removes only the targeted
255// entry. This is the keystone behavior of TASK-1228: `pad auth logout`

Callers

nothing calls this directly

Calls 3

newEmptyStoreFunction · 0.85
GetMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected