file_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. package opencode_test
  3. import (
  4. "context"
  5. "errors"
  6. "os"
  7. "testing"
  8. "github.com/sst/opencode-sdk-go"
  9. "github.com/sst/opencode-sdk-go/internal/testutil"
  10. "github.com/sst/opencode-sdk-go/option"
  11. )
  12. func TestFileRead(t *testing.T) {
  13. t.Skip("skipped: tests are disabled for the time being")
  14. baseURL := "http://localhost:4010"
  15. if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
  16. baseURL = envURL
  17. }
  18. if !testutil.CheckTestServer(t, baseURL) {
  19. return
  20. }
  21. client := opencode.NewClient(
  22. option.WithBaseURL(baseURL),
  23. )
  24. _, err := client.File.Read(context.TODO(), opencode.FileReadParams{
  25. Path: opencode.F("path"),
  26. })
  27. if err != nil {
  28. var apierr *opencode.Error
  29. if errors.As(err, &apierr) {
  30. t.Log(string(apierr.DumpRequest(true)))
  31. }
  32. t.Fatalf("err should be nil: %s", err.Error())
  33. }
  34. }
  35. func TestFileStatus(t *testing.T) {
  36. t.Skip("skipped: tests are disabled for the time being")
  37. baseURL := "http://localhost:4010"
  38. if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
  39. baseURL = envURL
  40. }
  41. if !testutil.CheckTestServer(t, baseURL) {
  42. return
  43. }
  44. client := opencode.NewClient(
  45. option.WithBaseURL(baseURL),
  46. )
  47. _, err := client.File.Status(context.TODO())
  48. if err != nil {
  49. var apierr *opencode.Error
  50. if errors.As(err, &apierr) {
  51. t.Log(string(apierr.DumpRequest(true)))
  52. }
  53. t.Fatalf("err should be nil: %s", err.Error())
  54. }
  55. }