(t *testing.T)
| 92 | } |
| 93 | |
| 94 | func 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 | |
| 121 | func TestMigrationErrorsWhenPreVersionMismatch(t *testing.T) { |
| 122 | StubWriteConfig(t) |
nothing calls this directly
no test coverage detected