Bugfix/134 wait for deletion of configmap#142
Conversation
|
Is missing in BackupSchedules, doesn't it? |
|
Sonarqube is unhappy with test coverage :( |
| } | ||
|
|
||
| err = migration.WaitForDeletion(func() error { | ||
| _, terror := repo.Get(ctx, doguName) |
There was a problem hiding this comment.
is terror a thing or a typo? shouldn't we write it t_error or something (i am not even sure what the t is meaning - probably timeout)?
| mockRepo.EXPECT().Get(testCtx, doguName).Return(regConfig.DoguConfig{}, apierrors.NewNotFound( | ||
| schema.GroupResource{ | ||
| Group: "", | ||
| Resource: "configmaps", | ||
| }, | ||
| doguName.String(), | ||
| )) | ||
|
|
There was a problem hiding this comment.
I feel like this is adding much bloat to every positive test. Should we introduce a file-wide variable? Or at least remove the Group and Resource, since they are not checked anyways?
| oldWaitFunc := migration.WaitForDeletion | ||
| migration.WaitForDeletion = func(check func() error) error { | ||
| return nil | ||
| } | ||
| defer func() { | ||
| migration.WaitForDeletion = oldWaitFunc | ||
| }() |
There was a problem hiding this comment.
So why no global-config tests?
There was a problem hiding this comment.
to keep the unittests as they were
- added another test for specificly testing wait function on global-config
…g' into bugfix/134-wait-for-deletion-of-configmap # Conflicts: # CHANGELOG.md # migration/config/dogu.go # migration/config/dogu_test.go
…r-deletion-of-configmap
There was a problem hiding this comment.
// importDoguConfigWithRepo imports a dogu configuration into a doguConfigRepo by wiping the
// existing config and refilling it. Excluded keys are restored to their original values, or
// skipped if they didn't exist before the import.
| } | ||
| } else { | ||
| return fmt.Errorf("failed to get original dogu config: %w", err) | ||
| } |
There was a problem hiding this comment.
change the order of operations to remove the second get:
registryDoguConfig, err := repo.Get(ctx, doguName)
slog.Debug(fmt.Sprintf("old dogu config %s: %v", doguName, registryDoguConfig))
if err != nil {
if !ceserrors.IsNotFoundError(err) && !apierrors.IsNotFound(err) {
return fmt.Errorf("failed to get original dogu config: %w", err)
}
registryDoguConfig, err = repo.Create(ctx, regConfig.CreateDoguConfig(doguName, map[regConfig.Key]regConfig.Value{}))
if err != nil {
return fmt.Errorf("failed to create new dogu config: %w", err)
}
}
originalValues := registryDoguConfig
| if err != nil { | ||
| return fmt.Errorf("failed to create new dogu config: %w", err) | ||
| } | ||
| //whipe out old config |
There was a problem hiding this comment.
add a little context:
// wipe out old config so we overwrite instead of merging with old values.
or something
No description provided.