-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
auth: refactor auth store test to use common setup #7234
Conversation
I am not sure how refactoring test failed etcd/integration tests https://jenkins-etcd-public.prod.coreos.systems/job/etcd-proxy/563/console ` goroutine 124588 [running]: |
Current coverage is 64.05% (diff: 100%)
|
@@ -34,32 +34,35 @@ func dummyIndexWaiter(index uint64) <-chan struct{} { | |||
return ch | |||
} | |||
|
|||
func TestUserAdd(t *testing.T) { | |||
func setupAuthStore(t *testing.T) (*authStore, func(t *testing.T)) { |
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 use named return here? func(t *testing.T) is very unclear.
(store *authStore, teardownfunc func(t *testing.T))
|
||
as := NewAuthStore(b, dummyIndexWaiter) | ||
ua := &pb.AuthUserAddRequest{Name: "foo"} | ||
roleAddErr := enableAuthAndCreateRoot(as) |
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.
err := xxx
if err != ErrUserEmpty { | ||
t.Fatal(err) | ||
tearDown := func(t *testing.T) { | ||
func() { |
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 do we need this nested func()?
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.
good point. I carried away while moving code 😄 Updating PR.
Minor issues. LGTM after fixing them. Defer to @mitake |
Refactored tests to pull common setup into a method.
a55aa86
to
fa1cbd5
Compare
I have pushed changes recommended by @xiang90. |
@Rushit lgtm, thanks! The failed test isn't related to the change of this PR, so merging it. |
Refactored auth store tests to pull common setup into a method.
as per https://github.com/coreos/etcd/pull/7229/files/1b9a4d891148eca86d28ef051676f1eb5e49fa00
/cc @xiang90 @mitake