feat: shadow test workflow
This commit is contained in:
parent
a0d0612bd6
commit
fe1077ed08
28
tests/diff.go
Normal file
28
tests/diff.go
Normal file
@ -0,0 +1,28 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func diff(target string) {
|
||||
// 创建一个命令对象
|
||||
cmd := exec.Command("git", "diff", target)
|
||||
|
||||
// 创建一个字节缓冲区来存储输出结果
|
||||
var output bytes.Buffer
|
||||
|
||||
// 将命令的输出连接到字节缓冲区
|
||||
cmd.Stdout = &output
|
||||
|
||||
// 执行命令
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// 打印输出结果
|
||||
fmt.Println(output.String())
|
||||
}
|
26
tests/diff_test.go
Normal file
26
tests/diff_test.go
Normal file
@ -0,0 +1,26 @@
|
||||
package tests
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_diff(t *testing.T) {
|
||||
type args struct {
|
||||
target string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
{
|
||||
name: "test",
|
||||
args: args{
|
||||
target: "1a3484",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
diff(tt.args.target)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user