> ## Documentation Index
> Fetch the complete documentation index at: https://www.c1.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Test

> Test runs a function's test suite in a sandboxed environment and returns the results.



## OpenAPI

````yaml https://spec.speakeasy.com/conductor-one/conductorone/my-source-with-code-samples post /api/v1/functions/{function_id}/test
openapi: 3.1.0
info:
  description: The C1 API is a HTTP API for managing C1 resources.
  title: C1 API
  version: 0.1.0-alpha
servers:
  - description: The C1 API server for the current tenant.
    url: https://{tenantDomain}.conductor.one
    variables:
      tenantDomain:
        default: example
        description: The domain of the tenant to use for this request.
security:
  - bearerAuth: []
    oauth: []
paths:
  /api/v1/functions/{function_id}/test:
    post:
      tags:
        - Function
      summary: Test
      description: >-
        Test runs a function's test suite in a sandboxed environment and returns
        the results.
      operationId: c1.api.functions.v1.FunctionsService.Test
      parameters:
        - in: path
          name: function_id
          required: true
          schema:
            description: The function ID to test.
            readOnly: false
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/c1.api.functions.v1.FunctionsServiceTestRequestInput
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/c1.api.functions.v1.FunctionsServiceTestResponse
          description: FunctionsServiceTestResponse contains test execution results.
      x-codeSamples:
        - lang: go
          label: Test
          source: "package main\n\nimport(\n\t\"context\"\n\t\"github.com/conductorone/conductorone-sdk-go/pkg/models/shared\"\n\tconductoronesdkgo \"github.com/conductorone/conductorone-sdk-go\"\n\t\"github.com/conductorone/conductorone-sdk-go/pkg/models/operations\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := conductoronesdkgo.New(\n        conductoronesdkgo.WithSecurity(shared.Security{\n            BearerAuth: \"<YOUR_BEARER_TOKEN_HERE>\",\n            Oauth: \"<YOUR_OAUTH_HERE>\",\n        }),\n    )\n\n    res, err := s.Functions.Test(ctx, operations.C1APIFunctionsV1FunctionsServiceTestRequest{\n        FunctionID: \"<id>\",\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.FunctionsServiceTestResponse != nil {\n        // handle response\n    }\n}"
        - lang: typescript
          label: Typescript (SDK)
          source: >-
            import { ConductoroneSDKTypescript } from
            "conductorone-sdk-typescript";


            const conductoroneSDKTypescript = new ConductoroneSDKTypescript({
              security: {
                bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
                oauth: "<YOUR_OAUTH_HERE>",
              },
            });


            async function run() {
              const result = await conductoroneSDKTypescript.functions.test({
                functionId: "<id>",
              });

              console.log(result);
            }


            run();
components:
  schemas:
    c1.api.functions.v1.FunctionsServiceTestRequestInput:
      description: >-
        FunctionsServiceTestRequest runs tests for a function at a specific
        commit.
      properties:
        commitId:
          description: The commit ID to test. If empty, the published commit is used.
          readOnly: false
          type: string
      title: Functions Service Test Request
      type: object
      x-speakeasy-name-override: FunctionsServiceTestRequest
    c1.api.functions.v1.FunctionsServiceTestResponse:
      description: FunctionsServiceTestResponse contains test execution results.
      properties:
        result:
          $ref: '#/components/schemas/c1.api.functions.v1.FunctionTestResult'
        results:
          description: All test results.
          items:
            $ref: '#/components/schemas/c1.api.functions.v1.FunctionTestResult'
          nullable: true
          readOnly: false
          type: array
      title: Functions Service Test Response
      type: object
      x-speakeasy-name-override: FunctionsServiceTestResponse
    c1.api.functions.v1.FunctionTestResult:
      description: FunctionTestResult contains the result of a single test case execution.
      properties:
        assertions:
          description: The assertions evaluated during the test.
          items:
            $ref: >-
              #/components/schemas/c1.api.functions.v1.FunctionTestResult.FunctionTestResultAssertion
          nullable: true
          readOnly: false
          type: array
        error:
          description: Error message if the test errored (distinct from assertion failure).
          readOnly: false
          type: string
        logs:
          description: The log entries captured during the test.
          items:
            $ref: >-
              #/components/schemas/c1.api.functions.v1.FunctionTestResult.FunctionTestResultLog
          nullable: true
          readOnly: false
          type: array
        name:
          description: The test name.
          readOnly: false
          type: string
        status:
          description: The test result status.
          enum:
            - FUNCTION_TEST_RESULT_STATUS_UNSPECIFIED
            - FUNCTION_TEST_RESULT_STATUS_OK
            - FUNCTION_TEST_RESULT_STATUS_FAIL
            - FUNCTION_TEST_RESULT_STATUS_SKIPPED
          readOnly: false
          type: string
          x-speakeasy-unknown-values: allow
      title: Function Test Result
      type: object
      x-speakeasy-name-override: FunctionTestResult
    c1.api.functions.v1.FunctionTestResult.FunctionTestResultAssertion:
      description: A single assertion within a test.
      properties:
        actual:
          description: The actual value.
          readOnly: false
          type: string
        at:
          description: Source location of the assertion.
          readOnly: false
          type: string
        description:
          description: Description of the assertion.
          readOnly: false
          type: string
        expected:
          description: The expected value.
          readOnly: false
          type: string
        operator:
          description: The comparison operator (e.g., "==", "!=").
          readOnly: false
          type: string
        pass:
          description: Whether the assertion passed.
          readOnly: false
          type: boolean
      title: Function Test Result Assertion
      type: object
      x-speakeasy-name-override: FunctionTestResultAssertion
    c1.api.functions.v1.FunctionTestResult.FunctionTestResultLog:
      description: A log entry captured during a test.
      properties:
        level:
          description: The log level (e.g., "info", "error").
          readOnly: false
          type: string
        log:
          description: The log message content.
          readOnly: false
          type: string
        source:
          description: The log source (e.g., "stdout", "stderr").
          readOnly: false
          type: string
      title: Function Test Result Log
      type: object
      x-speakeasy-name-override: FunctionTestResultLog
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http
    oauth:
      description: >-
        This API uses OAuth2 with the Client Credential flow.

        Client Credentials must be sent in the BODY, not the headers.

        For an example of how to implement this, refer to the
        [c1TokenSource.Token()](https://github.com/ConductorOne/conductorone-sdk-go/blob/3375fe7c0126d17e7ec4e711693dee7b791023aa/token_source.go#L101-L187)
        function.
      flows:
        clientCredentials:
          scopes: {}
          tokenUrl: /auth/v1/token
      type: oauth2

````