mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Add distinct IP counter
This commit is contained in:
parent
97dea533da
commit
211254fa98
8 changed files with 307 additions and 0 deletions
33
common/ipsetsink/sinkcluster/writer_test.go
Normal file
33
common/ipsetsink/sinkcluster/writer_test.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
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)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue