All Downloads are FREE. Search and download functionalities are using the official Maven repository.

common.ipsetsink.sinkcluster.writer_test.go Maven / Gradle / Ivy

There is a newer version: 2.9.1
Show newest version
package sinkcluster

import (
	"bytes"
	"io"
	"testing"
	"time"

	"git.torproject.org/pluggable-transports/snowflake.git/v2/common/ipsetsink"

	. "github.com/smartystreets/goconvey/convey"
)

type writerStub struct {
	io.Writer
}

func (w writerStub) Sync() error {
	return nil
}

func TestSinkWriter(t *testing.T) {

	Convey("Context", t, func() {
		buffer := bytes.NewBuffer(nil)
		writerStubInst := &writerStub{buffer}
		sink := ipsetsink.NewIPSetSink("demo")
		clusterWriter := NewClusterWriter(writerStubInst, time.Minute, sink)
		clusterWriter.AddIPToSet("1")
		clusterWriter.WriteIPSetToDisk()
		So(buffer.Bytes(), ShouldNotBeNil)
	})
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy