-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test add to actions memcached & add some tests
- Loading branch information
Showing
6 changed files
with
261 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package memcached | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/aliexpressru/gomemcached/consistenthash" | ||
) | ||
|
||
func TestWithOptions(t *testing.T) { | ||
const ( | ||
maxIdleConns = 10 | ||
disable = true | ||
enable | ||
authUser = "admin" | ||
authPass = "password" | ||
timeout = 5 * time.Second | ||
period = time.Second | ||
) | ||
|
||
hr := consistenthash.NewCustomHashRing(1, nil) | ||
os.Setenv("MEMCACHED_SERVERS", "localhost:11211") | ||
mcl, _ := InitFromEnv( | ||
WithMaxIdleConns(maxIdleConns), | ||
WithTimeout(timeout), | ||
WithCustomHashRing(hr), | ||
WithPeriodForNodeHealthCheck(period), | ||
WithPeriodForRebuildingNodes(period), | ||
WithDisableNodeProvider(), | ||
WithDisableRefreshConnsInPool(), | ||
WithDisableMemcachedDiagnostic(), | ||
WithAuthentication(authUser, authPass), | ||
) | ||
t.Cleanup(func() { | ||
mcl.CloseAllConns() | ||
}) | ||
|
||
assert.Equal(t, maxIdleConns, mcl.maxIdleConns, "WithMaxIdleConns should set maxIdleConns") | ||
assert.Equal(t, timeout, mcl.timeout, "WithTimeout should set timeout") | ||
assert.Equal(t, hr, mcl.hr, "WithCustomHashRing should set hr") | ||
assert.Equal(t, period, mcl.nodeHCPeriod, "WithPeriodForNodeHealthCheck should set period") | ||
assert.Equal(t, period, mcl.nodeRBPeriod, "WithPeriodForRebuildingNodes should set period") | ||
assert.Equal(t, disable, mcl.disableNodeProvider, "WithDisableNodeProvider should set disable") | ||
assert.Equal(t, disable, mcl.disableRefreshConns, "WithDisableRefreshConnsInPool should set disable") | ||
assert.Equal(t, disable, mcl.disableMemcachedDiagnostic, "WithDisableMemcachedDiagnostic should set disable") | ||
assert.Equal(t, enable, mcl.authEnable, "WithAuthentication should set enable") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters