Skip to content

Commit

Permalink
ci: fix testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Mar 22, 2024
1 parent 96bdf9a commit 99e82b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 31 deletions.
32 changes: 2 additions & 30 deletions internal/module/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package html

import (
lua "github.com/yuin/gopher-lua"
"testing"

lua "github.com/yuin/gopher-lua"
)

func TestRequire(t *testing.T) {
Expand All @@ -30,35 +31,6 @@ func TestRequire(t *testing.T) {
evalLua(str, t)
}

func TestFind(t *testing.T) {
const str = `
local file = require("file")
file.symlink(src, dest)
assert(div:text() == "hello world")
`
evalLua(str, t)
}

func TestFirst(t *testing.T) {
const str = `
local html = require("html")
local doc = html.parse("<html><body><div id='test'>123</div><div id='test'>456</div></body></html>")
local div = doc:find("div")
assert(div:first():text() == "123")
`
evalLua(str, t)
}

func TestContinuousFind(t *testing.T) {
const str = `
local html = require("html")
local doc = html.parse("<html><body><div id='test'>test</div><div id='t2'>456</div></body></html>")
local div = doc:find("body"):find("#t2")
print(div:text() == "456")
`
evalLua(str, t)
}

func evalLua(str string, t *testing.T) {
s := lua.NewState()
defer s.Close()
Expand Down
13 changes: 12 additions & 1 deletion internal/printer/select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ package printer

import (
"fmt"
"os"
"testing"

"github.com/pterm/pterm"
)

func TestSelect_Show(t *testing.T) {
if os.Getenv("CI") != "" {
t.Skip("Skipping TestSelect_Show in CI environment because it requires user input")
}

source := []*KV{
{
Key: "1",
Expand All @@ -46,7 +53,7 @@ func TestSelect_Show(t *testing.T) {
}
s := &PageKVSelect{
index: 0,
SourceFunc: func(page, size int) ([]*KV, error) {
SourceFunc: func(page, size int, options []*KV) ([]*KV, error) {
// 计算开始和结束索引
start := page * size
end := start + size
Expand All @@ -69,4 +76,8 @@ func TestSelect_Show(t *testing.T) {
if err != nil {
t.Fatal(err)
}

t.Cleanup(func() {
pterm.DefaultArea.Stop()
})
}

0 comments on commit 99e82b2

Please sign in to comment.