> ## Documentation Index
> Fetch the complete documentation index at: https://conductorone-docs-mcp-bridge-private-server.mintlify.site/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.
            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.
          type:
            - string
            - 'null'
      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:
          oneOf:
            - $ref: '#/components/schemas/c1.api.functions.v1.FunctionTestResult'
            - type: 'null'
        results:
          description: All test results.
          items:
            $ref: '#/components/schemas/c1.api.functions.v1.FunctionTestResult'
          type:
            - array
            - 'null'
      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
          type:
            - array
            - 'null'
        error:
          description: Error message if the test errored (distinct from assertion failure).
          type:
            - string
            - 'null'
        logs:
          description: The log entries captured during the test.
          items:
            $ref: >-
              #/components/schemas/c1.api.functions.v1.FunctionTestResult.FunctionTestResultLog
          type:
            - array
            - 'null'
        name:
          description: The test name.
          type:
            - string
            - 'null'
        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
          type:
            - string
            - 'null'
          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.
          type:
            - string
            - 'null'
        at:
          description: Source location of the assertion.
          type:
            - string
            - 'null'
        description:
          description: Description of the assertion.
          type:
            - string
            - 'null'
        expected:
          description: The expected value.
          type:
            - string
            - 'null'
        operator:
          description: The comparison operator (e.g., "==", "!=").
          type:
            - string
            - 'null'
        pass:
          description: Whether the assertion passed.
          type:
            - boolean
            - 'null'
      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").
          type:
            - string
            - 'null'
        log:
          description: The log message content.
          type:
            - string
            - 'null'
        source:
          description: The log source (e.g., "stdout", "stderr").
          type:
            - string
            - 'null'
      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

````