Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBZ-7155 Add Unit Tests for ServiceAccountDependent Class #26

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

ilyasahsan123
Copy link
Contributor

@ilyasahsan123 ilyasahsan123 commented Nov 18, 2023

@ilyasahsan123
Copy link
Contributor Author

hi @jcechace,

Could you please take a look on this PR to add unittests on the ServiceAccountDependent class.

Thank you

@ilyasahsan123 ilyasahsan123 changed the title DBZ-TBA Create Unittests for ServiceAccountDependent Class DBZ-TBA Add Unit Tests for ServiceAccountDependent Class Nov 18, 2023
@ilyasahsan123 ilyasahsan123 changed the title DBZ-TBA Add Unit Tests for ServiceAccountDependent Class DBZ-7155 Add Unit Tests for ServiceAccountDependent Class Nov 18, 2023
}

@Test
void shouldReturnManagerServiceAccount() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilyasahsan123 this should probably read shouldReturnManagedServiceAccount

ServiceAccount serviceAccount = serviceAccountDependent.desired(debeziumServer, context);

assertThat(serviceAccount.getMetadata().getName()).isEqualTo(managedSaName);
assertThat(serviceAccount.getMetadata().getNamespace()).isEqualTo("default");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default is the default so IMHO it might be best to change the namespace first and tests with that.

}

@Test
void shouldDesiredServiceAccount() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely should read shouldReturnDesiredServiceAccount

@jcechace jcechace self-requested a review November 18, 2023 19:11
Copy link
Member

@jcechace jcechace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilyasahsan123 Also please squash the commits. Thanks!


@AfterEach
void after() {
client.resource(debeziumServer).delete();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilyasahsan123 since this is a unit test we are not really creating the object within kubernetes (we shouldn't). So I don't think this is required. Consequently the client field itself is not required.

Comment on lines 26 to 24
private final String dsName = "test-ds";
private final String saName = "test-ds-service-account";
private final String managedSaName = "test-ds-sa";
private final String namespace = "debezium";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could be constants, no?

Comment on lines 23 to 24
private final String managedSaName = "test-ds-sa";
private final String namespace = "debezium";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Just convert these two into constants (e.g. private static final String MANAGED_SA_NAME) and I will merge it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. 👍

add end of lines

Reformat the file

Fix the failed CI by sorting the imports.

Fix the failed CI by adding Class header.

Implement Suggestion from peer review

refactor the code

Remove Kubernetes Client

Rename constant variables
Copy link
Member

@jcechace jcechace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing!

@jcechace jcechace merged commit c52f086 into debezium:main Nov 20, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants