MCPcopy Index your code
hub / github.com/cli/cli / TestMigrationIsNoopWhenAlreadyApplied

Function TestMigrationIsNoopWhenAlreadyApplied

internal/config/migrate_test.go:94–119  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestMigrationIsNoopWhenAlreadyApplied(t *testing.T) {
95 // Given we have a migration with a post version that matches
96 // the version in the config
97 c := ghConfig.ReadFromString(testFullConfig())
98 c.Set([]string{versionKey}, "expected-post-version")
99
100 migration := &ghmock.MigrationMock{
101 DoFunc: func(config *ghConfig.Config) error {
102 return errors.New("is not called")
103 },
104 PreVersionFunc: func() string {
105 return "is not called"
106 },
107 PostVersionFunc: func() string {
108 return "expected-post-version"
109 },
110 }
111
112 // When we run Migrate
113 conf := cfg{c}
114 err := conf.Migrate(migration)
115
116 // Then there is nothing done and the config is not modified
117 require.NoError(t, err)
118 requireKeyWithValue(t, c, []string{versionKey}, "expected-post-version")
119}
120
121func TestMigrationErrorsWhenPreVersionMismatch(t *testing.T) {
122 StubWriteConfig(t)

Callers

nothing calls this directly

Calls 4

MigrateMethod · 0.95
testFullConfigFunction · 0.85
requireKeyWithValueFunction · 0.70
SetMethod · 0.65

Tested by

no test coverage detected