a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
37 lines
758 B
Go
37 lines
758 B
Go
package gortex
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestEngine_IndexAndQuery(t *testing.T) {
|
|
dir := t.TempDir()
|
|
require.NoError(t, os.WriteFile(filepath.Join(dir, "main.go"), []byte(`package main
|
|
|
|
func Hello() {}
|
|
func World() { Hello() }
|
|
`), 0o644))
|
|
|
|
eng := New(WithWorkers(1))
|
|
result, err := eng.Index(dir)
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, 1, result.FileCount)
|
|
assert.Greater(t, result.NodeCount, 0)
|
|
|
|
// FindSymbols.
|
|
nodes := eng.FindSymbols("Hello")
|
|
require.Len(t, nodes, 1)
|
|
assert.Equal(t, "Hello", nodes[0].Name)
|
|
|
|
// Stats.
|
|
stats := eng.Stats()
|
|
assert.Greater(t, stats.TotalNodes, 0)
|
|
assert.Equal(t, stats.TotalNodes, result.NodeCount)
|
|
}
|