file_test.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 TestFileListWithOptionalParams(t *testing.T) {
  13. t.Skip("Prism tests are disabled")
  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.List(context.TODO(), opencode.FileListParams{
  25. Path: opencode.F("path"),
  26. Directory: opencode.F("directory"),
  27. })
  28. if err != nil {
  29. var apierr *opencode.Error
  30. if errors.As(err, &apierr) {
  31. t.Log(string(apierr.DumpRequest(true)))
  32. }
  33. t.Fatalf("err should be nil: %s", err.Error())
  34. }
  35. }
  36. func TestFileReadWithOptionalParams(t *testing.T) {
  37. t.Skip("Prism tests are disabled")
  38. baseURL := "http://localhost:4010"
  39. if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
  40. baseURL = envURL
  41. }
  42. if !testutil.CheckTestServer(t, baseURL) {
  43. return
  44. }
  45. client := opencode.NewClient(
  46. option.WithBaseURL(baseURL),
  47. )
  48. _, err := client.File.Read(context.TODO(), opencode.FileReadParams{
  49. Path: opencode.F("path"),
  50. Directory: opencode.F("directory"),
  51. })
  52. if err != nil {
  53. var apierr *opencode.Error
  54. if errors.As(err, &apierr) {
  55. t.Log(string(apierr.DumpRequest(true)))
  56. }
  57. t.Fatalf("err should be nil: %s", err.Error())
  58. }
  59. }
  60. func TestFileStatusWithOptionalParams(t *testing.T) {
  61. t.Skip("Prism tests are disabled")
  62. baseURL := "http://localhost:4010"
  63. if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
  64. baseURL = envURL
  65. }
  66. if !testutil.CheckTestServer(t, baseURL) {
  67. return
  68. }
  69. client := opencode.NewClient(
  70. option.WithBaseURL(baseURL),
  71. )
  72. _, err := client.File.Status(context.TODO(), opencode.FileStatusParams{
  73. Directory: opencode.F("directory"),
  74. })
  75. if err != nil {
  76. var apierr *opencode.Error
  77. if errors.As(err, &apierr) {
  78. t.Log(string(apierr.DumpRequest(true)))
  79. }
  80. t.Fatalf("err should be nil: %s", err.Error())
  81. }
  82. }