Skip to content

Commit

Permalink
test: modified UserQuota tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joragua committed Oct 21, 2024
1 parent c5b2699 commit 81b58d5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class OCRemoteUserDataSourceTest {
used = OC_USER_QUOTA.used,
free = OC_USER_QUOTA.available,
relative = OC_USER_QUOTA.getRelative(),
total = OC_USER_QUOTA.getTotal()
total = OC_USER_QUOTA.total
)
private val remoteAvatar = RemoteAvatarData(
avatarData = OC_USER_AVATAR.avatarData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,32 @@ class UserQuotaTest {
val item = UserQuota(
"",
800,
200
200,
1000,
"normal"
)

assertEquals(800, item.available)
assertEquals(200, item.used)
assertEquals(1000, item.total)
}

@Test
fun testEqualsOk() {
val item1 = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = 800,
used = 200
used = 200,
total = 1000,
state = "normal"
)

val item2 = UserQuota(
OC_ACCOUNT_NAME,
800,
200
200,
1000,
"normal"
)

assertTrue(item1 == item2)
Expand All @@ -60,13 +67,17 @@ class UserQuotaTest {
val item1 = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = 800,
used = 200
used = 200,
total = 1000,
state = "normal"
)

val item2 = UserQuota(
OC_ACCOUNT_NAME,
1000,
200
200,
1000,
"normal"
)

assertFalse(item1 == item2)
Expand All @@ -78,62 +89,74 @@ class UserQuotaTest {
val item = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = 800_000_000,
used = 20_000_000
used = 20_000_000,
total = 820_000_000,
state = "normal"
)

assertTrue(item.getTotal() == 820_000_000.toLong())
assertTrue(item.total == 820_000_000.toLong())
}

@Test
fun testGetTotalFullQuota() {
val item = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = 0,
used = 20_000_000
used = 20_000_000,
total = 0,
state = "normal"
)

assertTrue(item.getTotal() == 0.toLong())
assertTrue(item.total == 0.toLong())
}

@Test
fun testGetTotalUnlimitedQuota() {
val item1 = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = -3,
used = 20_000_000
used = 20_000_000,
total = 0,
state = "normal"
)

assertTrue(item1.getTotal() == 0.toLong())
assertTrue(item1.total == 0.toLong())
}

@Test
fun testQuotaLimited() {
val item = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = 200_000,
used = 20_000
used = 20_000,
total = 220_000,
state = "normal"
)

assertTrue(item.isLimited())
assertTrue(item.available > 0)
}

@Test
fun testQuotaUnLimited() {
val item = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = -3,
used = 20_000
used = 20_000,
total = 0,
state = "normal"
)

assertFalse(item.isLimited())
assertFalse(item.available > 0)
}

@Test
fun testGetRelativeUnlimited() {
val item = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = -3,
used = 20_000
used = 20_000,
total = 0,
state = "normal"
)

assertEquals(0.0, item.getRelative(), 0.0001)
Expand All @@ -144,7 +167,9 @@ class UserQuotaTest {
val item = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = 80_000,
used = 20_000
used = 20_000,
total = 100_000,
state = "normal"
)

assertEquals(20.0, item.getRelative(), 0.0001)
Expand All @@ -155,7 +180,9 @@ class UserQuotaTest {
val item = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = 0,
used = 0
used = 0,
total = 0,
state = "normal"
)

assertEquals(0.0, item.getRelative(), 0.0001)
Expand All @@ -166,7 +193,9 @@ class UserQuotaTest {
val item = UserQuota(
accountName = OC_ACCOUNT_NAME,
available = 75_000,
used = 20_000
used = 20_000,
total = 95_000,
state = "normal"
)

assertEquals(21.05, item.getRelative(), 0.0001)
Expand Down

0 comments on commit 81b58d5

Please sign in to comment.