make validCreate function so the tests look a little nicer.

This commit is contained in:
idk
2018-08-22 10:55:36 -04:00
parent a57ebd8e7e
commit 299080f4c2

View File

@ -26,6 +26,12 @@ func (c *Client) validCmd(str string, args ...interface{}) (string, error) {
return "", fmt.Errorf("Error, invalid input")
}
func (c *Client) validCreate() (string, error) {
id := rand.Int31n(math.MaxInt32)
result, err := c.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions())
return result, err
}
func TestOptionAddrString(t *testing.T) {
client, err := NewClientFromOptions(SetAddr("127.0.0.1:7656"), SetDebug(true))
if err != nil {
@ -34,8 +40,8 @@ func TestOptionAddrString(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -50,8 +56,8 @@ func TestOptionAddrStringLh(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -66,8 +72,8 @@ func TestOptionAddrSlice(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -82,8 +88,8 @@ func TestOptionAddrMixedSlice(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -98,8 +104,8 @@ func TestOptionHost(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -114,8 +120,8 @@ func TestOptionPort(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -130,8 +136,8 @@ func TestOptionPortInt(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -146,8 +152,8 @@ func TestOptionDebug(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -163,8 +169,8 @@ func TestOptionInLength(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -180,8 +186,8 @@ func TestOptionOutLength(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -197,8 +203,8 @@ func TestOptionInVariance(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -214,8 +220,8 @@ func TestOptionOutVariance(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -231,8 +237,8 @@ func TestOptionInQuantity(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -248,8 +254,8 @@ func TestOptionOutQuantity(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -265,8 +271,8 @@ func TestOptionInBackups(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -282,8 +288,8 @@ func TestOptionOutBackups(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -298,8 +304,8 @@ func TestOptionEncryptLease(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -314,8 +320,8 @@ func TestOptionUnpublishedLease(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -330,8 +336,8 @@ func TestOptionReduceIdle(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -346,8 +352,8 @@ func TestOptionReduceIdleTime(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -362,8 +368,8 @@ func TestOptionReduceIdleCount(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -378,8 +384,8 @@ func TestOptionCloseIdle(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)
@ -394,8 +400,8 @@ func TestOptionCloseIdleTime(t *testing.T) {
if err := client.Close(); err != nil {
t.Fatalf("client.Close() Error: %q\n", err)
}
id := rand.Int31n(math.MaxInt32)
if result, err := client.validCmd("SESSION CREATE STYLE=STREAM ID=%d DESTINATION=%s %s\n", id, "abc.i2p", client.allOptions()); err != nil {
if result, err := client.validCreate(); err != nil {
t.Fatalf(err.Error())
} else {
t.Log(result)