mirror of
https://github.com/sst/opencode.git
synced 2025-08-22 22:14:14 +00:00

The concept of mode has been deprecated, there is now only the agent field in the config. An agent can be cycled through as your primary agent with <tab> or you can spawn a subagent by @ mentioning it. if you include a description of when to use it, the primary agent will try to automatically use it Full docs here: https://opencode.ai/docs/agents/
131 lines
3.2 KiB
Go
131 lines
3.2 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 TestAppAgents(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.App.Agents(context.TODO())
|
|
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 TestAppGet(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.App.Get(context.TODO())
|
|
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 TestAppInit(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.App.Init(context.TODO())
|
|
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 TestAppLogWithOptionalParams(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.App.Log(context.TODO(), opencode.AppLogParams{
|
|
Level: opencode.F(opencode.AppLogParamsLevelDebug),
|
|
Message: opencode.F("message"),
|
|
Service: opencode.F("service"),
|
|
Extra: opencode.F(map[string]interface{}{
|
|
"foo": "bar",
|
|
}),
|
|
})
|
|
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 TestAppProviders(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.App.Providers(context.TODO())
|
|
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())
|
|
}
|
|
}
|