Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Feat [Golang] [Module] Main Command #21

Merged
merged 2 commits into from
Dec 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Test [Golang] [Module] Main Command Testing purposes.
- [+] test(main_test.go): refactor TestProcessCSVOption to use a mock file system
- [+] fix(main_test.go): restore stdout after capturing output
  • Loading branch information
H0llyW00dzZ committed Dec 9, 2023
commit f79547b89bf6ffff98c2999eadc7b982e59ddff8
8 changes: 4 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ func TestProcessCSVOption(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

// Save the current stdout (usually the terminal) so it can be restored after the test.
oldStdout := os.Stdout
defer func() { os.Stdout = oldStdout }()
// Create an instance of the mock file system
mockFS := &filesystem.MockFileSystem{}

// Redirect stdout to a pipe where we can capture the output of the function.
r, w, _ := os.Pipe()
oldStdout := os.Stdout
os.Stdout = w

// Invoke the processCSVOption function, which should process the input and generate a CSV file.
processCSVOption(ctx, reader, store.ChatNextWebStore.Sessions)
processCSVOption(mockFS, ctx, reader, store.ChatNextWebStore.Sessions)

// Close the write-end of the pipe to finish capturing the output.
w.Close()
Expand Down
Loading