mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
33 lines
663 B
Go
33 lines
663 B
Go
package sinkcluster
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"testing"
|
|
"time"
|
|
|
|
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/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)
|
|
})
|
|
}
|