(t *testing.T)
| 151 | } |
| 152 | |
| 153 | func TestMigrationErrorWritesNoFiles(t *testing.T) { |
| 154 | tempDir := t.TempDir() |
| 155 | t.Setenv("GH_CONFIG_DIR", tempDir) |
| 156 | |
| 157 | // Given we have a migrator that errors |
| 158 | c := ghConfig.ReadFromString(testFullConfig()) |
| 159 | migration := mockMigration(func(config *ghConfig.Config) error { |
| 160 | return errors.New("failed to migrate in test") |
| 161 | }) |
| 162 | |
| 163 | // When we run the migration |
| 164 | conf := cfg{c} |
| 165 | err := conf.Migrate(migration) |
| 166 | |
| 167 | // Then the error is wrapped and bubbled |
| 168 | require.EqualError(t, err, "failed to migrate config: failed to migrate in test") |
| 169 | |
| 170 | // And no files are written to disk |
| 171 | files, err := os.ReadDir(tempDir) |
| 172 | require.NoError(t, err) |
| 173 | require.Len(t, files, 0) |
| 174 | } |
| 175 | |
| 176 | func TestMigrationWriteErrors(t *testing.T) { |
| 177 | tests := []struct { |
nothing calls this directly
no test coverage detected