2018-07-16 02:49:03 -04:00
|
|
|
package goSam
|
|
|
|
|
2018-08-21 22:52:19 -04:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"math"
|
|
|
|
"math/rand"
|
2018-08-22 17:57:50 -04:00
|
|
|
//"net/http"
|
2018-08-21 22:52:19 -04:00
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// helper to validate sendCmd inputs
|
|
|
|
func (c *Client) validCmd(str string, args ...interface{}) (string, error) {
|
|
|
|
if s := fmt.Sprintf(str, args...); strings.Contains(s, "\n") {
|
|
|
|
sl := strings.Split(s, "\n")
|
|
|
|
if len(sl) == 2 {
|
2018-08-22 01:46:52 -04:00
|
|
|
if sl[1] != "" {
|
2018-08-22 08:57:38 -04:00
|
|
|
return sl[1], fmt.Errorf("Error, there should be no options after the newline")
|
2018-08-22 01:46:52 -04:00
|
|
|
}
|
2018-08-21 22:52:19 -04:00
|
|
|
for li, in := range sl {
|
2018-08-22 01:46:52 -04:00
|
|
|
fmt.Println(li, in)
|
|
|
|
}
|
2018-08-21 22:52:19 -04:00
|
|
|
return s, nil
|
|
|
|
}
|
|
|
|
return "", fmt.Errorf("Error, invalid length: %d", len(sl))
|
|
|
|
}
|
|
|
|
return "", fmt.Errorf("Error, invalid input")
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
|
2018-08-22 10:55:36 -04:00
|
|
|
func (c *Client) validCreate() (string, error) {
|
|
|
|
id := rand.Int31n(math.MaxInt32)
|
2018-08-22 18:02:13 -04:00
|
|
|
result, err := c.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions())
|
2018-08-22 10:55:36 -04:00
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
|
2018-07-16 02:49:03 -04:00
|
|
|
func TestOptionAddrString(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetAddr("127.0.0.1:7656"), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionAddrStringLh(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetAddr("localhost:7656"), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionAddrSlice(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetAddr("127.0.0.1", "7656"), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionAddrMixedSlice(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetAddrMixed("127.0.0.1", 7656), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionHost(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetHost("127.0.0.1"), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionPort(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetPort("7656"), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionPortInt(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetPortInt(7656), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionDebug(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionInLength(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetInLength(3), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.inlength()
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionOutLength(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetInLength(3), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.outlength()
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionInVariance(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetInVariance(1), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.invariance()
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionOutVariance(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetOutVariance(1), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.outvariance()
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionInQuantity(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetInQuantity(6), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.inquantity()
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionOutQuantity(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetOutQuantity(6), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.outquantity()
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionInBackups(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetInBackups(5), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.inbackups()
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionOutBackups(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetOutBackups(5), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.outbackups()
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionEncryptLease(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetEncrypt(true), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionUnpublishedLease(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetUnpublished(true), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-07-16 02:49:03 -04:00
|
|
|
}
|
2018-08-05 00:53:28 -04:00
|
|
|
|
|
|
|
func TestOptionReduceIdle(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetReduceIdle(true), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-08-05 00:53:28 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-08-05 00:53:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionReduceIdleTime(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetReduceIdleTime(300001), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-08-05 00:53:28 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-08-05 00:53:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionReduceIdleCount(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetReduceIdleQuantity(4), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-08-05 00:53:28 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
|
|
|
|
2018-08-05 00:53:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionCloseIdle(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetCloseIdle(true), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-08-05 00:53:28 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-08-05 00:53:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOptionCloseIdleTime(t *testing.T) {
|
|
|
|
client, err := NewClientFromOptions(SetCloseIdleTime(300001), SetDebug(true))
|
|
|
|
if err != nil {
|
2018-08-22 17:57:50 -04:00
|
|
|
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
|
2018-08-05 00:53:28 -04:00
|
|
|
}
|
2018-08-22 10:55:36 -04:00
|
|
|
if result, err := client.validCreate(); err != nil {
|
2018-08-22 01:46:52 -04:00
|
|
|
t.Fatalf(err.Error())
|
|
|
|
} else {
|
|
|
|
t.Log(result)
|
|
|
|
}
|
2018-08-22 17:57:50 -04:00
|
|
|
client.CreateStreamSession("")
|
|
|
|
if err := client.Close(); err != nil {
|
|
|
|
t.Fatalf("client.Close() Error: %q\n", err)
|
|
|
|
}
|
2018-08-05 00:53:28 -04:00
|
|
|
}
|