Skip to content

Commit

Permalink
fixup! fix: add integration tests for NAB
Browse files Browse the repository at this point in the history
Signed-off-by: Mateus Oliveira <[email protected]>
  • Loading branch information
mateusoliveira43 committed Aug 30, 2024
1 parent 8082cb3 commit ebc22d7
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 299 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ editorconfig: $(LOCALBIN) ## Download editorconfig locally if necessary.
}

# TODO increase to 60?
COVERAGE_THRESHOLD=30
COVERAGE_THRESHOLD=40

.PHONY: ci
ci: simulation-test lint docker-build hadolint check-generate check-manifests ec check-images ## Run all project continuous integration (CI) checks locally.
Expand Down
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func main() {
if err = (&controller.NonAdminBackupReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
// TODO context does not need to be set here???
// add env var here?? so it is only called once still and is easy to test
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "NonAdminBackup")
os.Exit(1)
Expand Down
10 changes: 5 additions & 5 deletions internal/common/function/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func GetBackupSpecFromNonAdminBackup(nonAdminBackup *nacv1alpha1.NonAdminBackup)
veleroBackupSpec.IncludedNamespaces = []string{nonAdminBackup.Namespace}
} else {
if !containsOnlyNamespace(veleroBackupSpec.IncludedNamespaces, nonAdminBackup.Namespace) {
return nil, fmt.Errorf("spec.backupSpec.IncludedNamespaces can not contain namespaces other then: %s", nonAdminBackup.Namespace)
return nil, fmt.Errorf("spec.backupSpec.IncludedNamespaces can not contain namespaces other than: %s", nonAdminBackup.Namespace)
}
}

Expand Down Expand Up @@ -228,10 +228,10 @@ func UpdateNonAdminBackupCondition(ctx context.Context, r client.Client, logger
},
)

// TODO ... Condition *set* to... ?
logger.V(1).Info(fmt.Sprintf("NonAdminBackup Condition to: %s", condition))
logger.V(1).Info(fmt.Sprintf("NonAdminBackup Condition Reason to: %s", reason))
logger.V(1).Info(fmt.Sprintf("NonAdminBackup Condition Message to: %s", message))
// TODO these logs should be after err check, no?
logger.V(1).Info(fmt.Sprintf("NonAdminBackup Condition set to: %s", condition))
logger.V(1).Info(fmt.Sprintf("NonAdminBackup Condition Reason set to: %s", reason))
logger.V(1).Info(fmt.Sprintf("NonAdminBackup Condition Message set to: %s", message))

// Update NAB status
if err := r.Status().Update(ctx, nab); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/common/function/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func TestGetBackupSpecFromNonAdminBackup(t *testing.T) {

assert.Error(t, err)
assert.Nil(t, backupSpec)
assert.Equal(t, "spec.backupSpec.IncludedNamespaces can not contain namespaces other then: namespace2", err.Error())
assert.Equal(t, "spec.backupSpec.IncludedNamespaces can not contain namespaces other than: namespace2", err.Error())

backupSpecInput = &velerov1api.BackupSpec{
IncludedNamespaces: []string{"namespace3"},
Expand All @@ -237,7 +237,7 @@ func TestGetBackupSpecFromNonAdminBackup(t *testing.T) {

assert.Error(t, err)
assert.Nil(t, backupSpec)
assert.Equal(t, "spec.backupSpec.IncludedNamespaces can not contain namespaces other then: namespace4", err.Error())
assert.Equal(t, "spec.backupSpec.IncludedNamespaces can not contain namespaces other than: namespace4", err.Error())
}

func TestGenerateVeleroBackupName(t *testing.T) {
Expand Down
269 changes: 69 additions & 200 deletions internal/controller/nonadminbackup_controller.go

Large diffs are not rendered by default.

Loading

0 comments on commit ebc22d7

Please sign in to comment.