Now unpack the file and move it to the tests folder in the project root.
Unit Tests
Unit tests have been implemented for parts of the core functionality. Currently there are basic tests for reading pcap data from files and traffic live from an interface, as well as tests and benchmarks for common utility functions, such progress displaying and time conversions.
The tests and benchmarks can be executed from the repository root by executing the following from the project root:
$ go test -v ./...
=== RUN TestCountRecords
--- PASS: TestCountRecords (0.18s)
=== RUN TestReader
--- PASS: TestReader (0.01s)
=== RUN TestWriter
--- PASS: TestWriter (0.06s)
PASS
ok github.com/dreadl0ck/netcap 0.862s
? github.com/dreadl0ck/netcap/cmd [no test files]
? github.com/dreadl0ck/netcap/cmd/agent [no test files]
? github.com/dreadl0ck/netcap/cmd/capture [no test files]
? github.com/dreadl0ck/netcap/cmd/collect [no test files]
? github.com/dreadl0ck/netcap/cmd/dump [no test files]
? github.com/dreadl0ck/netcap/cmd/export [no test files]
? github.com/dreadl0ck/netcap/cmd/label [no test files]
? github.com/dreadl0ck/netcap/cmd/proxy [no test files]
? github.com/dreadl0ck/netcap/cmd/split [no test files]
? github.com/dreadl0ck/netcap/cmd/transform [no test files]
? github.com/dreadl0ck/netcap/cmd/util [no test files]
=== RUN TestCollectPCA
done in 2.595847118s
--- PASS: TestCollectPCAP (2.60s)
PASS
ok github.com/dreadl0ck/netcap/collector 3.242s
=== RUN TestCorruptedWriter
TestCorruptedWriter: delimited_test.go:46: Put record returned expected error: BAD
--- PASS: TestCorruptedWriter (0.00s)
=== RUN TestGoodWriter
--- PASS: TestGoodWriter (0.00s)
=== RUN TestCorruptedReader
TestCorruptedReader: delimited_test.go:87: Next record returned expected error: unexpected EOF
--- PASS: TestCorruptedReader (0.00s)
=== RUN TestGoodReader
--- PASS: TestGoodReader (0.00s)
=== RUN TestRoundTrip
TestRoundTrip: delimited_test.go:136: After writing: buffer="\x04Some\x02of\x04what\x01a\x04fool\x06thinks\x05often\bremains." len=42
--- PASS: TestRoundTrip (0.00s)
PASS
ok github.com/dreadl0ck/netcap/delimited 0.526s
? github.com/dreadl0ck/netcap/dpi [no test files]
? github.com/dreadl0ck/netcap/encoder [no test files]
? github.com/dreadl0ck/netcap/io [no test files]
? github.com/dreadl0ck/netcap/label [no test files]
? github.com/dreadl0ck/netcap/maltego [no test files]
? github.com/dreadl0ck/netcap/metrics [no test files]
? github.com/dreadl0ck/netcap/resolvers [no test files]
=== RUN TestMarshal
--- PASS: TestMarshal (0.00s)
PASS
ok github.com/dreadl0ck/netcap/types 0.668s
=== RUN TestTimeToString
--- PASS: TestTimeToString (0.00s)
=== RUN TestStringToTime
--- PASS: TestStringToTime (0.00s)
PASS
ok github.com/dreadl0ck/netcap/utils 0.932s