MCPcopy
hub / github.com/cli/cli / TestMigration

Function TestMigration

internal/config/migration/multi_account_test.go:15–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestMigration(t *testing.T) {
16 cfg := config.ReadFromString(`
17hosts:
18 github.com:
19 user: user1
20 oauth_token: xxxxxxxxxxxxxxxxxxxx
21 git_protocol: ssh
22 enterprise.com:
23 user: user2
24 oauth_token: yyyyyyyyyyyyyyyyyyyy
25 git_protocol: https
26`)
27
28 var m migration.MultiAccount
29 require.NoError(t, m.Do(cfg))
30
31 // First we'll check that the oauth tokens have been moved to their new locations
32 requireKeyWithValue(t, cfg, []string{"hosts", "github.com", "users", "user1", "oauth_token"}, "xxxxxxxxxxxxxxxxxxxx")
33 requireKeyWithValue(t, cfg, []string{"hosts", "enterprise.com", "users", "user2", "oauth_token"}, "yyyyyyyyyyyyyyyyyyyy")
34
35 // Then we'll check that the old data has been left alone
36 requireKeyWithValue(t, cfg, []string{"hosts", "github.com", "user"}, "user1")
37 requireKeyWithValue(t, cfg, []string{"hosts", "github.com", "oauth_token"}, "xxxxxxxxxxxxxxxxxxxx")
38 requireKeyWithValue(t, cfg, []string{"hosts", "github.com", "git_protocol"}, "ssh")
39
40 requireKeyWithValue(t, cfg, []string{"hosts", "enterprise.com", "user"}, "user2")
41 requireKeyWithValue(t, cfg, []string{"hosts", "enterprise.com", "oauth_token"}, "yyyyyyyyyyyyyyyyyyyy")
42 requireKeyWithValue(t, cfg, []string{"hosts", "enterprise.com", "git_protocol"}, "https")
43}
44
45func TestMigrationSecureStorage(t *testing.T) {
46 cfg := config.ReadFromString(`

Callers

nothing calls this directly

Calls 2

DoMethod · 0.95
requireKeyWithValueFunction · 0.70

Tested by

no test coverage detected