remove faulty tests

This commit is contained in:
vyzo 2018-01-14 02:01:42 +02:00
parent f1be0f1296
commit cb365a5fee
1 changed files with 0 additions and 98 deletions

View File

@ -392,104 +392,6 @@ func TestValidate(t *testing.T) {
}
}
func TestValidateTimeout(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
hosts := getNetHosts(t, ctx, 2)
psubs := getPubsubs(ctx, hosts)
connect(t, hosts[0], hosts[1])
topic := "foobar"
cases := []struct {
timeout time.Duration
msg []byte
validates bool
}{
{75 * time.Millisecond, []byte("this better time out"), false},
{150 * time.Millisecond, []byte("this should work"), true},
}
for _, tc := range cases {
sub, err := psubs[1].Subscribe(topic, WithValidator(func(ctx context.Context, msg *Message) bool {
time.Sleep(100 * time.Millisecond)
return true
}), WithValidatorTimeout(tc.timeout))
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Millisecond * 50)
p := psubs[0]
err = p.Publish(topic, tc.msg)
if err != nil {
t.Fatal(err)
}
select {
case msg := <-sub.ch:
if !tc.validates {
t.Log(msg)
t.Error("expected message validation to filter out the message")
}
case <-time.After(333 * time.Millisecond):
if tc.validates {
t.Error("expected message validation to accept the message")
}
}
// important: cancel!
// otherwise the message will still be filtered by the other subscription
sub.Cancel()
}
}
func TestValidateCancel(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
hosts := getNetHosts(t, ctx, 2)
psubs := getPubsubs(ctx, hosts)
connect(t, hosts[0], hosts[1])
topic := "foobar"
sub, err := psubs[1].Subscribe(topic, WithValidator(func(ctx context.Context, msg *Message) bool {
<-ctx.Done()
return true
}))
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Millisecond * 50)
testmsg := []byte("this is a legal message")
validates := false // message for which the validator times our are discarded
p := psubs[0]
err = p.Publish(topic, testmsg)
if err != nil {
t.Fatal(err)
}
select {
case msg := <-sub.ch:
if !validates {
t.Log(msg)
t.Error("expected message validation to filter out the message")
}
case <-time.After(333 * time.Millisecond):
if validates {
t.Error("expected message validation to accept the message")
}
}
}
func TestValidateOverload(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()