-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BEAM-13870] [Playground] Increase test coverage for the cache package #16826
[BEAM-13870] [Playground] Increase test coverage for the cache package #16826
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are LGTM, could you please also add comments to all others so it is easier to read them? That would help very much, thanks!
// Test case with calling GetValue method with exist value the expiration time of which has ended. | ||
// As a result, want to receive an error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding these comments, could you please also add comments for other tests in these files? So every test in local_cache_test.go
and redis_cache_test.go
has a corresponding comment😊
{ | ||
// Test case with calling startGC method with nil items. | ||
// As a result, items stay the same. | ||
name: "Checking for deleting expired pipelines with nil items", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
want *Cache | ||
}{ | ||
{ | ||
// Test case with calling New method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -243,6 +243,23 @@ func TestRedisCache_SetValue(t *testing.T) { | |||
}, | |||
wantErr: false, | |||
}, | |||
{ | |||
// Test case with calling SetValue method with incorrect value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -535,6 +555,28 @@ func Test_unmarshalBySubKey(t *testing.T) { | |||
want: output, | |||
wantErr: false, | |||
}, | |||
{ | |||
// Test case with calling unmarshalBySubKey method with Canceled subKey. | |||
// As a result, want to receive false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it will be false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daria-malkova because canceledValue
is JSON encoding of the false.
}{ | ||
{ | ||
// Test case with calling SetExpTime method with pipelineId and his expiration time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -103,6 +105,23 @@ func TestLocalCache_GetValue(t *testing.T) { | |||
want: nil, | |||
wantErr: true, | |||
}, | |||
{ | |||
// Test case with calling GetValue method with existing value that is expiring. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unuseful comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -159,6 +178,23 @@ func TestLocalCache_SetValue(t *testing.T) { | |||
}, | |||
wantErr: false, | |||
}, | |||
{ | |||
// Test case with calling SetValue method with RunOutputIndex subKey. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
wantErr: false, | ||
}, | ||
{ | ||
// Test case with calling SetExpTime method with pipelineId which not set in cache and expiration time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -68,7 +68,7 @@ func TestRedisCache_GetValue(t *testing.T) { | |||
wantErr: true, | |||
}, | |||
{ | |||
name: "all success", | |||
name: "get existing value", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes you have a name with an upper case letter, but sometimes with lower case. Do the same everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, let's start all test names with upper case letters.
E.g. here
name: "get existing value", | |
name: "Get existing value", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's finalize the naming and address Daria's comments. Then we'll be good to go🙂
@@ -68,7 +68,7 @@ func TestRedisCache_GetValue(t *testing.T) { | |||
wantErr: true, | |||
}, | |||
{ | |||
name: "all success", | |||
name: "get existing value", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, let's start all test names with upper case letters.
E.g. here
name: "get existing value", | |
name: "Get existing value", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
R: @pabloem |
LGTM |
[BEAM-13870]
Add unit tests to increase test coverage for the cache package
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username
).[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
ValidatesRunner
compliance status (on master branch)Examples testing status on various runners
Post-Commit SDK/Transform Integration Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.