Skip to content

Commit

Permalink
Load env in tests
Browse files Browse the repository at this point in the history
Co-Authored-By: Liza Tsibur <[email protected]>
  • Loading branch information
caffeinatedpixel and lisaSW committed Jul 10, 2024
1 parent 3dcd4d1 commit b64dccb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions importer/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import (

"github.com/activecm/rita/v5/importer/zeektypes"
"github.com/activecm/rita/v5/util"
"github.com/joho/godotenv"

"github.com/spf13/afero"
"github.com/stretchr/testify/require"
)

func TestTruncatedTSV(t *testing.T) {
err := godotenv.Load("../.env")
require.NoError(t, err)

path := "../test_data/truncated/conn.log"
entries := make(chan zeektypes.Conn)
errc := make(chan error)
Expand Down Expand Up @@ -60,6 +64,9 @@ func TestTruncatedTSV(t *testing.T) {
}

func TestTruncatedHeader(t *testing.T) {
err := godotenv.Load("../.env")
require.NoError(t, err)

path := "../test_data/truncated/conn_top.log"
entries := make(chan zeektypes.Conn)
errc := make(chan error)
Expand Down Expand Up @@ -104,6 +111,9 @@ func TestTruncatedHeader(t *testing.T) {
}

func TestTruncatedJSON(t *testing.T) {
err := godotenv.Load("../.env")
require.NoError(t, err)

path := "../test_data/truncated/conn_json.log"
entries := make(chan zeektypes.Conn)
errc := make(chan error)
Expand Down Expand Up @@ -150,6 +160,9 @@ func TestTruncatedJSON(t *testing.T) {
}

func TestHasUnknownFieldTSV(t *testing.T) {
err := godotenv.Load("../.env")
require.NoError(t, err)

path := "../test_data/has_unknown_field/http.log"

entries := make(chan zeektypes.HTTP)
Expand Down Expand Up @@ -201,6 +214,9 @@ func TestHasUnknownFieldTSV(t *testing.T) {
}

func TestPlainTextFile(t *testing.T) {
err := godotenv.Load("../.env")
require.NoError(t, err)

path := "../test_data/text_file/conn.log"

entries := make(chan zeektypes.Conn)
Expand Down
4 changes: 4 additions & 0 deletions logger/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import (
"sync"
"testing"

"github.com/joho/godotenv"
"github.com/stretchr/testify/require"
)

func TestLoggerNil(t *testing.T) {
err := godotenv.Load("../.env")
require.NoError(t, err)

logger := GetLogger()
require.NotNil(t, logger, "logger cannot be nil")

Expand Down

0 comments on commit b64dccb

Please sign in to comment.