You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
769 B
Go
35 lines
769 B
Go
package internal
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/zeromicro/go-zero/core/stringx"
|
|
)
|
|
|
|
func TestAccount(t *testing.T) {
|
|
endpoints := []string{
|
|
"192.168.0.2:2379",
|
|
"192.168.0.3:2379",
|
|
"192.168.0.4:2379",
|
|
}
|
|
username := "foo" + stringx.Rand()
|
|
password := "bar"
|
|
anotherPassword := "any"
|
|
|
|
_, ok := GetAccount(endpoints)
|
|
assert.False(t, ok)
|
|
|
|
AddAccount(endpoints, username, password)
|
|
account, ok := GetAccount(endpoints)
|
|
assert.True(t, ok)
|
|
assert.Equal(t, username, account.User)
|
|
assert.Equal(t, password, account.Pass)
|
|
|
|
AddAccount(endpoints, username, anotherPassword)
|
|
account, ok = GetAccount(endpoints)
|
|
assert.True(t, ok)
|
|
assert.Equal(t, username, account.User)
|
|
assert.Equal(t, anotherPassword, account.Pass)
|
|
}
|