Skip to content

Commit

Permalink
Merge pull request #14618 from ahrtr/username_password_cont
Browse files Browse the repository at this point in the history
test: add common function "WithAuth"
  • Loading branch information
ahrtr authored Oct 25, 2022
2 parents f215cd8 + 3ee2f57 commit b37532d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
10 changes: 9 additions & 1 deletion tests/common/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@

package common

import "go.etcd.io/etcd/tests/v3/framework"
import (
"go.etcd.io/etcd/tests/v3/framework"
"go.etcd.io/etcd/tests/v3/framework/config"
"go.etcd.io/etcd/tests/v3/framework/e2e"
)

func init() {
testRunner = framework.E2eTestRunner
}

func WithAuth(userName, password string) config.ClientOption {
return e2e.WithAuth(userName, password)
}
6 changes: 6 additions & 0 deletions tests/common/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ package common

import (
"go.etcd.io/etcd/tests/v3/framework"
"go.etcd.io/etcd/tests/v3/framework/config"
"go.etcd.io/etcd/tests/v3/framework/integration"
)

func init() {
testRunner = framework.IntegrationTestRunner
}

func WithAuth(userName, password string) config.ClientOption {
return integration.WithAuth(userName, password)
}
7 changes: 4 additions & 3 deletions tests/framework/config/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import (
)

// ClientOption configures the client with additional parameter.
// For example, if Auth is enabled,
// 1. e2e test cases use e2e.WithAuth to return a ClientOption;
// 2. integration test, uses integration.WithAuth to return a ClientOption.
// For example, if Auth is enabled, the common test cases just need to
// use `WithAuth` to return a ClientOption. Note that the common `WithAuth`
// function calls `e2e.WithAuth` or `integration.WithAuth`, depending on the
// build tag (either "e2e" or "integration").
type ClientOption func(any)

type GetOptions struct {
Expand Down

0 comments on commit b37532d

Please sign in to comment.