From 45214fa225b182bf44e8d80c51cefb1a648adbe6 Mon Sep 17 00:00:00 2001 From: HAHWUL Date: Fri, 6 Dec 2024 23:21:50 +0900 Subject: [PATCH] Add initial test for main function in dalfox_test.go Signed-off-by: HAHWUL --- dalfox_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 dalfox_test.go diff --git a/dalfox_test.go b/dalfox_test.go new file mode 100644 index 00000000..de9b15a9 --- /dev/null +++ b/dalfox_test.go @@ -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) + } + }) + } +}