Skip to content

Commit

Permalink
refactor: renamed some tests and variables and added necessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
joragua committed Dec 12, 2024
1 parent ed41732 commit 6b70f03
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class OCFolderBackupRepositoryTest {
private val pictureUploadsName = "Pictures uploads"

@Test
fun `getAutomaticUploadsConfiguration returns AutomaticUploadsConfiguration`() {
fun `getAutomaticUploadsConfiguration returns an AutomaticUploadsConfiguration`() {
every {
localFolderBackupDataSource.getAutomaticUploadsConfiguration()
} returns OC_AUTOMATIC_UPLOADS_CONFIGURATION
Expand All @@ -56,7 +56,7 @@ class OCFolderBackupRepositoryTest {
}

@Test
fun `getAutomaticUploadsConfiguration returns null when local data source returns a null configuration`() {
fun `getAutomaticUploadsConfiguration returns null when local datasource returns a null configuration`() {
every {
localFolderBackupDataSource.getAutomaticUploadsConfiguration()
} returns null
Expand Down Expand Up @@ -84,7 +84,7 @@ class OCFolderBackupRepositoryTest {
}

@Test
fun `getFolderBackupConfigurationByNameAsFlow returns a Flow with null when local data source returns a Flow with null `() = runTest {
fun `getFolderBackupConfigurationByNameAsFlow returns a Flow with null when local datasource returns a Flow with null `() = runTest {
every {
localFolderBackupDataSource.getFolderBackupConfigurationByNameAsFlow(pictureUploadsName)
} returns flowOf(null)
Expand All @@ -107,7 +107,7 @@ class OCFolderBackupRepositoryTest {
}

@Test
fun `resetFolderBackupConfigurationByName resets a folder backup configuration correctly by the name`() {
fun `resetFolderBackupConfigurationByName resets a folder backup configuration by name correctly`() {
ocFolderBackupRepository.resetFolderBackupConfigurationByName(pictureUploadsName)

verify(exactly = 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class OCServerInfoRepositoryTest {
}

@Test
fun `getServerInfo returns a BasicServer when creatingAccount parameter is true and webfinger datasource returns null`() {
fun `getServerInfo returns a BasicServer when creatingAccount parameter is true and webfinger datasource throws an exception`() {
every {
remoteWebFingerDataSource.getInstancesFromWebFinger(
lookupServer = OC_SECURE_SERVER_INFO_BASIC_AUTH.baseUrl,
Expand Down Expand Up @@ -95,7 +95,7 @@ class OCServerInfoRepositoryTest {
}

@Test
fun `getServerInfo returns an OAuthServer when creatingAccount parameter is false`() {
fun `getServerInfo returns an OAuth2Server when creatingAccount parameter is false`() {
every {
remoteServerInfoDataSource.getServerInfo(OC_SECURE_SERVER_INFO_BEARER_AUTH.baseUrl, false)
} returns OC_SECURE_SERVER_INFO_BEARER_AUTH
Expand All @@ -118,7 +118,7 @@ class OCServerInfoRepositoryTest {
}

@Test
fun `getServerInfo returns an OAuthServer when creatingAccount parameter is true and webfinger datasource returns null`() {
fun `getServerInfo returns an OAuth2Server when creatingAccount parameter is true and webfinger datasource throws an exception`() {
every {
remoteWebFingerDataSource.getInstancesFromWebFinger(
lookupServer = OC_SECURE_SERVER_INFO_BEARER_AUTH.baseUrl,
Expand Down Expand Up @@ -177,7 +177,7 @@ class OCServerInfoRepositoryTest {
}

@Test
fun `getServerInfo returns an OIDCServer when creatingAccount parameter is true and web finger datasource returns null`() {
fun `getServerInfo returns an OIDCServer when creatingAccount parameter is true and webfinger datasource throws an exception`() {
every {
remoteWebFingerDataSource.getInstancesFromWebFinger(
lookupServer = OC_SECURE_SERVER_INFO_OIDC_AUTH.baseUrl,
Expand Down Expand Up @@ -213,7 +213,7 @@ class OCServerInfoRepositoryTest {
}

@Test
fun `getServerInfo returns an OIDCServer when creatingAccount is true and web finger data source returns an instance`() {
fun `getServerInfo returns an OIDCServer when creatingAccount is true and webfinger datasource returns an OIDC issuer`() {
every {
remoteWebFingerDataSource.getInstancesFromWebFinger(
lookupServer = OC_SECURE_SERVER_INFO_OIDC_AUTH_WEBFINGER_INSTANCE.baseUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.junit.Test
class OCShareeRepositoryTest {

private val remoteShareeDataSource = mockk<RemoteShareeDataSource>(relaxUnitFun = true)
private val oCShareeRepository = OCShareeRepository(remoteShareeDataSource)
private val ocShareeRepository = OCShareeRepository(remoteShareeDataSource)

private val searchString = "user"
private val requestedPage = 1
Expand All @@ -45,7 +45,7 @@ class OCShareeRepositoryTest {
remoteShareeDataSource.getSharees(searchString, requestedPage, resultsPerPage, OC_ACCOUNT_NAME)
} returns listOf(OC_SHAREE)

val listOfSharees = oCShareeRepository.getSharees(searchString, requestedPage, resultsPerPage, OC_ACCOUNT_NAME)
val listOfSharees = ocShareeRepository.getSharees(searchString, requestedPage, resultsPerPage, OC_ACCOUNT_NAME)
assertEquals(listOf(OC_SHAREE), listOfSharees)

verify(exactly = 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class OCShareRepositoryTest {

every {
localShareDataSource.insert(OC_PRIVATE_SHARE)
} returns 1
} returns 1 // The result of this method is not used, so it can be anything

ocShareRepository.insertPrivateShare(filePath, OC_PRIVATE_SHARE.shareType, OC_SHAREE.shareWith, permissions, OC_ACCOUNT_NAME)

Expand Down Expand Up @@ -100,7 +100,7 @@ class OCShareRepositoryTest {

every {
localShareDataSource.update(OC_PRIVATE_SHARE)
} returns 1
} returns 1 // The result of this method is not used, so it can be anything

ocShareRepository.updatePrivateShare(OC_PRIVATE_SHARE.remoteId, permissions, OC_ACCOUNT_NAME)

Expand Down Expand Up @@ -134,7 +134,7 @@ class OCShareRepositoryTest {

every {
localShareDataSource.insert(OC_PUBLIC_SHARE)
} returns 1
} returns 1 // The result of this method is not used, so it can be anything

ocShareRepository.insertPublicShare(filePath, permissions, OC_PUBLIC_SHARE.name!!, password, expiration, OC_ACCOUNT_NAME)

Expand Down Expand Up @@ -168,7 +168,7 @@ class OCShareRepositoryTest {

every {
localShareDataSource.update(OC_PUBLIC_SHARE)
} returns 1
} returns 1 // The result of this method is not used, so it can be anything

ocShareRepository.updatePublicShare(OC_PUBLIC_SHARE.remoteId, OC_PUBLIC_SHARE.name!!, password, expiration, permissions, OC_ACCOUNT_NAME)

Expand Down Expand Up @@ -226,7 +226,7 @@ class OCShareRepositoryTest {
}

@Test
fun `refreshSharesFromNetwork refreshes shares correctly when the list of shares is not empty`() {
fun `refreshSharesFromNetwork refreshes shares correctly when the list of shares received is not empty`() {
every {
remoteShareDataSource.getShares(
remoteFilePath = filePath,
Expand All @@ -238,7 +238,7 @@ class OCShareRepositoryTest {

every {
localShareDataSource.replaceShares(listOfShares)
} returns listOf(1, 1, 1, 1)
} returns listOf(1, 1) // The result of this method is not used, so it can be anything

ocShareRepository.refreshSharesFromNetwork(filePath, OC_ACCOUNT_NAME)

Expand All @@ -254,7 +254,7 @@ class OCShareRepositoryTest {
}

@Test
fun `refreshSharesFromNetwork refreshes shares correctly when the list of shares is empty`() {
fun `refreshSharesFromNetwork deletes local shares and refreshes shares correctly when the list of shares received is empty`() {
every {
remoteShareDataSource.getShares(
remoteFilePath = filePath,
Expand Down Expand Up @@ -286,7 +286,7 @@ class OCShareRepositoryTest {
fun `deleteShare deletes a share correctly`() {
every {
localShareDataSource.deleteShare(OC_SHARE.remoteId)
} returns 1
} returns 1 // The result of this method is not used, so it can be anything

ocShareRepository.deleteShare(OC_SHARE.remoteId, OC_ACCOUNT_NAME)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* ownCloud Android client application
*
* @author Jorge Aguado Recio
*
* Copyright (C) 2024 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
Expand Down

0 comments on commit 6b70f03

Please sign in to comment.