feat: load packet logs from configured source
This commit is contained in:
29
internal/isphere/file_source_test.go
Normal file
29
internal/isphere/file_source_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package isphere
|
||||
|
||||
import (
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoadEncryptedPacketLogSourceFromFileReadsNonEmptyLines(t *testing.T) {
|
||||
path := writePacketLogFileForTest(t, "\n encrypted-line-1 \r\n\r\n\tencrypted-line-2\n")
|
||||
|
||||
got, err := LoadEncryptedPacketLogSourceFromFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadEncryptedPacketLogSourceFromFile returned error: %v", err)
|
||||
}
|
||||
want := EncryptedPacketLogSource{Lines: []string{"encrypted-line-1", "encrypted-line-2"}}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("source = %#v, want %#v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func writePacketLogFileForTest(t *testing.T, content string) string {
|
||||
t.Helper()
|
||||
path := t.TempDir() + "\\packet.log"
|
||||
if err := os.WriteFile(path, []byte(content), 0o600); err != nil {
|
||||
t.Fatalf("write test packet log: %v", err)
|
||||
}
|
||||
return path
|
||||
}
|
||||
Reference in New Issue
Block a user