mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
86 lines
2.1 KiB
Go
86 lines
2.1 KiB
Go
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
|
|
package opencode_test
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/sst/opencode-sdk-go"
|
|
"github.com/sst/opencode-sdk-go/internal/testutil"
|
|
"github.com/sst/opencode-sdk-go/option"
|
|
)
|
|
|
|
func TestFindFiles(t *testing.T) {
|
|
t.Skip("skipped: tests are disabled for the time being")
|
|
baseURL := "http://localhost:4010"
|
|
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
|
baseURL = envURL
|
|
}
|
|
if !testutil.CheckTestServer(t, baseURL) {
|
|
return
|
|
}
|
|
client := opencode.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
)
|
|
_, err := client.Find.Files(context.TODO(), opencode.FindFilesParams{
|
|
Query: opencode.F("query"),
|
|
})
|
|
if err != nil {
|
|
var apierr *opencode.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestFindSymbols(t *testing.T) {
|
|
t.Skip("skipped: tests are disabled for the time being")
|
|
baseURL := "http://localhost:4010"
|
|
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
|
baseURL = envURL
|
|
}
|
|
if !testutil.CheckTestServer(t, baseURL) {
|
|
return
|
|
}
|
|
client := opencode.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
)
|
|
_, err := client.Find.Symbols(context.TODO(), opencode.FindSymbolsParams{
|
|
Query: opencode.F("query"),
|
|
})
|
|
if err != nil {
|
|
var apierr *opencode.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestFindText(t *testing.T) {
|
|
t.Skip("skipped: tests are disabled for the time being")
|
|
baseURL := "http://localhost:4010"
|
|
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
|
baseURL = envURL
|
|
}
|
|
if !testutil.CheckTestServer(t, baseURL) {
|
|
return
|
|
}
|
|
client := opencode.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
)
|
|
_, err := client.Find.Text(context.TODO(), opencode.FindTextParams{
|
|
Pattern: opencode.F("pattern"),
|
|
})
|
|
if err != nil {
|
|
var apierr *opencode.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|