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

Function TestMigrationErrorsWhenPreVersionMismatch

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

Source from the content-addressed store, hash-verified

119}
120
121func TestMigrationErrorsWhenPreVersionMismatch(t *testing.T) {
122 StubWriteConfig(t)
123
124 // Given we have a migration with a pre version that does not match
125 // the version in the config
126 c := ghConfig.ReadFromString(testFullConfig())
127 c.Set([]string{versionKey}, "not-expected-pre-version")
128 topLevelKey := []string{"toplevelkey"}
129
130 migration := &ghmock.MigrationMock{
131 DoFunc: func(config *ghConfig.Config) error {
132 config.Set(topLevelKey, "toplevelvalue")
133 return nil
134 },
135 PreVersionFunc: func() string {
136 return "expected-pre-version"
137 },
138 PostVersionFunc: func() string {
139 return "not-expected"
140 },
141 }
142
143 // When we run Migrate
144 conf := cfg{c}
145 err := conf.Migrate(migration)
146
147 // Then there is an error the migration is not applied and the version is not modified
148 require.ErrorContains(t, err, `failed to migrate as "expected-pre-version" pre migration version did not match config version "not-expected-pre-version"`)
149 requireNoKey(t, c, topLevelKey)
150 requireKeyWithValue(t, c, []string{versionKey}, "not-expected-pre-version")
151}
152
153func TestMigrationErrorWritesNoFiles(t *testing.T) {
154 tempDir := t.TempDir()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected