Skip to content

Commit

Permalink
Add initial test for main function in dalfox_test.go
Browse files Browse the repository at this point in the history
Signed-off-by: HAHWUL <[email protected]>
  • Loading branch information
hahwul committed Dec 6, 2024
1 parent be3e85c commit 45214fa
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions dalfox_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Code by @hahwul
Happy hacking :D
*/
package main

import (
"bytes"
"os"
"testing"
)

func Test_main(t *testing.T) {
tests := []struct {
name string
}{
{name: "Test case 1"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Redirect stdout to capture output
old := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w

// Call the main function
main()

// Capture the output
w.Close()
var buf bytes.Buffer
buf.ReadFrom(r)
os.Stdout = old

// Check the output
got := buf.String()
if len(got) > 0 {
t.Errorf("main() = %v, want %v", got, nil)
}
})
}
}

0 comments on commit 45214fa

Please sign in to comment.