diff --git a/.eslintrc.js b/.eslintrc.js index 390a22f..a1595c0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,12 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + module.exports = { env: { browser: false, diff --git a/.github/workflows/build.yml b/.github/workflows/build-test.yml similarity index 92% rename from .github/workflows/build.yml rename to .github/workflows/build-test.yml index b7f27c2..453a10f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build-test.yml @@ -1,5 +1,5 @@ --- -name: build app +name: build-test on: [push, pull_request] @@ -27,3 +27,5 @@ jobs: run: echo "Please run 'npm run format' before commiting the code!" - name: Run build run: npm run build + - name: Run Test + run: npm test diff --git a/.github/workflows/license-header-checker.yml b/.github/workflows/license-header-checker.yml new file mode 100644 index 0000000..d026f0b --- /dev/null +++ b/.github/workflows/license-header-checker.yml @@ -0,0 +1,12 @@ +--- +name: License Header Checker + +on: [push, pull_request] + +jobs: + license-header-checker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Add License Header + run: npx @kt3k/license-checker diff --git a/.licenserc.json b/.licenserc.json new file mode 100644 index 0000000..85e7ef2 --- /dev/null +++ b/.licenserc.json @@ -0,0 +1,33 @@ +{ + "**/*.*": [" Copyright OpenSearch Contributors", " SPDX-License-Identifier: Apache-2.0"], + "ignore": [ + ".prettierrc", + ".md", + ".flake8", + ".yml", + ".yaml", + ".bat", + ".json", + ".txt", + ".config", + ".swp", + "tests/tests_test_workflow/test_integ_workflow/integ_test/data/artifacts/", + "tests/tests_sign_workflow/data/signature/", + "tests/tests_assemble_workflow/data/artifacts/", + ".png", + "settings.gradle", + ".git", + ".lychee.excludes", + ".whitesource", + ".shellcheckrc", + ".lock", + ".gradle", + ".cert", + ".key", + ".jar", + ".gz", + ".toml", + ".ini", + "gradle/wrapper" + ] +} diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 0fa6ff0..2274fe4 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -10,7 +10,7 @@ This document contains a list of maintainers in this repo. See [opensearch-proje | Maintainer | GitHub ID | Affiliation | | --------------- | --------------------------------------------------- | ----------- | -| Saurabh Sing | [getsaurabh02](https://github.com/getsaurabh02) | Amazon | +| Saurabh Singh | [getsaurabh02](https://github.com/getsaurabh02) | Amazon | | Peter Zhu | [peterzhuamazon](https://github.com/peterzhuamazon) | Amazon | | Prudhvi Godithi | [prudhvigodithi](https://github.com/prudhvigodithi) | Amazon | | Sayali Gaikawad | [gaiksaya](https://github.com/gaiksaya) | Amazon | diff --git a/README.md b/README.md index bdc11fe..2e33f55 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The automation app utilizes the [Probot](https://probot.github.io/) framework an ### Service -A **Service** is an instance of the app that manages and manipulates specific `Resource` while performing defined `Operation`. +A `Service` is an instance of the app that manages and manipulates specific `Resource` while performing defined `Operation`. - **Resource**: Objects or entities the service will manage or modify, such as GitHub organizations, project, repositories, issues, etc. - **Operation**: A list of `Tasks` triggered by events with the resources. diff --git a/jest.config.js b/jest.config.js index 6d8f326..44ead85 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,7 @@ module.exports = { testEnvironment: 'node', - roots: ['/test'], // Points to 'test' directory where your test files live - testMatch: ['**/*.test.ts'], // Match test files ending with `.test.ts` + roots: ['/test'], + testMatch: ['**/*.test.ts'], transform: { '^.+\\.tsx?$': 'ts-jest', }, diff --git a/src/app.ts b/src/app.ts index 2e75fe9..b175718 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/call/create-issue-comment.ts b/src/call/create-issue-comment.ts index 094f145..6dab19e 100644 --- a/src/call/create-issue-comment.ts +++ b/src/call/create-issue-comment.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/call/github-merged-pulls-monitor.ts b/src/call/github-merged-pulls-monitor.ts index 4395d77..0a8aa39 100644 --- a/src/call/github-merged-pulls-monitor.ts +++ b/src/call/github-merged-pulls-monitor.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to @@ -10,7 +11,7 @@ // Description : Monitors the CI workflows of merged pull requests, providing metrics that give an overview of whether pull requests were merged without passing CI checks. import { Probot } from 'probot'; -import { OpensearchClient } from '../utility/opensearchclient'; +import { OpensearchClient } from '../utility/opensearch/opensearch-client'; export default async function githubMergedPullsMonitor(app: Probot, context: any): Promise { const pr = context.payload.pull_request; diff --git a/src/call/github-workflow-runs-monitor.ts b/src/call/github-workflow-runs-monitor.ts index 401879f..7f0368d 100644 --- a/src/call/github-workflow-runs-monitor.ts +++ b/src/call/github-workflow-runs-monitor.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to @@ -9,16 +10,16 @@ // Name : githubWorkflowRunsMonitor // Description : prints the githubWorkflowRunsMonitor output and indexes logData to OpenSearch // Arguments : -// - events : The list of events to monitor and index, from https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows. +// - events : The list of events to monitor and index, from https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows. import { Probot } from 'probot'; -import { OpensearchClient } from '../utility/opensearchclient'; +import { OpensearchClient } from '../utility/opensearch/opensearch-client'; -interface WorkflowRunEvents { +interface WorkflowRunMonitorArgs { events: string[]; } -export default async function githubWorkflowRunsMonitor(app: Probot, context: any, { events }: WorkflowRunEvents): Promise { +export default async function githubWorkflowRunsMonitor(app: Probot, context: any, { events }: WorkflowRunMonitorArgs): Promise { const job = context.payload.workflow_run; if (!events.includes(job?.event)) { diff --git a/src/call/print-to-console.ts b/src/call/print-to-console.ts index 02eab05..e7ca2a5 100644 --- a/src/call/print-to-console.ts +++ b/src/call/print-to-console.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/config/config.ts b/src/config/config.ts index 5ab7135..71dd2c0 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/config/operation-config.ts b/src/config/operation-config.ts index e66d28d..3da140b 100644 --- a/src/config/operation-config.ts +++ b/src/config/operation-config.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/config/resource-config.ts b/src/config/resource-config.ts index a66f2b3..c27efb0 100644 --- a/src/config/resource-config.ts +++ b/src/config/resource-config.ts @@ -1,3 +1,12 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + import { ProbotOctokit } from 'probot'; import { ResourceData, OrganizationData } from './types'; import { Resource } from '../service/resource/resource'; diff --git a/src/config/types.ts b/src/config/types.ts index 87442f2..854a264 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to @@ -44,5 +45,5 @@ export interface TaskData { } export interface TaskArgData { - [key: string]: string; + [key: string]: string | string[]; } diff --git a/src/service/operation/operation.ts b/src/service/operation/operation.ts index 5099c86..7a28b4d 100644 --- a/src/service/operation/operation.ts +++ b/src/service/operation/operation.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/service/operation/task.ts b/src/service/operation/task.ts index 0fb07b3..d8e155c 100644 --- a/src/service/operation/task.ts +++ b/src/service/operation/task.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/service/resource/entity.ts b/src/service/resource/entity.ts index 214ffa4..5e1f9dd 100644 --- a/src/service/resource/entity.ts +++ b/src/service/resource/entity.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/service/resource/issue.ts b/src/service/resource/issue.ts index 2128127..b711f8f 100644 --- a/src/service/resource/issue.ts +++ b/src/service/resource/issue.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/service/resource/organization.ts b/src/service/resource/organization.ts index 2d3b8b2..532c570 100644 --- a/src/service/resource/organization.ts +++ b/src/service/resource/organization.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/service/resource/project-field.ts b/src/service/resource/project-field.ts index 28081e9..360866f 100644 --- a/src/service/resource/project-field.ts +++ b/src/service/resource/project-field.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/service/resource/project.ts b/src/service/resource/project.ts index e8c87f3..97f3ce4 100644 --- a/src/service/resource/project.ts +++ b/src/service/resource/project.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/service/resource/repository.ts b/src/service/resource/repository.ts index 5bd7f91..19d0db3 100644 --- a/src/service/resource/repository.ts +++ b/src/service/resource/repository.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/service/resource/resource.ts b/src/service/resource/resource.ts index 7986b7e..b3ca5c4 100644 --- a/src/service/resource/resource.ts +++ b/src/service/resource/resource.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/service/service.ts b/src/service/service.ts index 638e692..65729db 100644 --- a/src/service/service.ts +++ b/src/service/service.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to @@ -14,7 +15,7 @@ import { Operation } from './operation/operation'; import { Task } from './operation/task'; import { ResourceConfig } from '../config/resource-config'; import { OperationConfig } from '../config/operation-config'; -import { octokitAuth } from '../utility/octokit'; +import { octokitAuth } from '../utility/probot/octokit'; export class Service { private name: string; diff --git a/src/utility/opensearchclient.ts b/src/utility/opensearch/opensearch-client.ts similarity index 98% rename from src/utility/opensearchclient.ts rename to src/utility/opensearch/opensearch-client.ts index 9a0a21f..af7a6b3 100644 --- a/src/utility/opensearchclient.ts +++ b/src/utility/opensearch/opensearch-client.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/src/utility/octokit.ts b/src/utility/probot/octokit.ts similarity index 90% rename from src/utility/octokit.ts rename to src/utility/probot/octokit.ts index ea287d5..5e0d2da 100644 --- a/src/utility/octokit.ts +++ b/src/utility/probot/octokit.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to diff --git a/test/call/github-merged-pulls-monitor.test.ts b/test/call/github-merged-pulls-monitor.test.ts new file mode 100644 index 0000000..ed43855 --- /dev/null +++ b/test/call/github-merged-pulls-monitor.test.ts @@ -0,0 +1,100 @@ +import githubMergedPullsMonitor from '../../src/call/github-merged-pulls-monitor'; +import { Probot, Logger } from 'probot'; +import { OpensearchClient } from '../../src/utility/opensearch/opensearch-client'; + +jest.mock('../../src/utility/opensearch/opensearch-client'); + +describe('githubMergedPullsMonitor', () => { + let app: Probot; + let context: any; + + beforeEach(() => { + app = new Probot({ appId: 1, secret: 'test', privateKey: 'test' }); + app.log = { + info: jest.fn(), + error: jest.fn(), + } as unknown as Logger; + context = { + payload: { + pull_request: { + merged: true, + number: 123, + html_url: 'https://github.com/org/repo/pull/123', + url: 'https://api.github.com/repos/org/repo/pulls/123', + user: { login: 'octocat' }, + created_at: '2023-09-25T12:00:00Z', + updated_at: '2023-09-26T12:00:00Z', + closed_at: '2023-09-26T13:00:00Z', + merged_at: '2023-09-26T14:00:00Z', + merged_by: { login: 'merger' }, + head: { sha: 'abcdef123456' }, + merge_commit_sha: 'fedcba654321', + }, + repository: { + name: 'repo', + owner: { login: 'org' }, + }, + }, + octokit: { + checks: { + listForRef: jest.fn().mockResolvedValue({ + data: { + check_runs: [ + { + id: 1, + name: 'Test Check', + conclusion: 'success', + status: 'completed', + started_at: '2023-09-26T13:00:00Z', + completed_at: '2023-09-26T14:00:00Z', + html_url: 'https://github.com/org/repo/checks/1', + url: 'https://api.github.com/repos/org/repo/check-runs/1', + }, + ], + }, + }), + }, + }, + log: { + info: jest.fn(), + error: jest.fn(), + }, + }; + }); + + it('should skip processing if the pull request is not merged', async () => { + context.payload.pull_request.merged = false; + await githubMergedPullsMonitor(app, context); + expect(app.log.info).toHaveBeenCalledWith('PR is closed but not merged. Skipping...'); + }); + + it('should index merged pull request check runs', async () => { + const mockBulkIndex = jest.spyOn(OpensearchClient.prototype, 'bulkIndex').mockResolvedValue(); + await githubMergedPullsMonitor(app, context); + expect(context.octokit.checks.listForRef).toHaveBeenCalledWith({ + owner: 'org', + repo: 'repo', + ref: 'abcdef123456', + }); + expect(mockBulkIndex).toHaveBeenCalledWith( + expect.stringMatching(/^github-pulls-ci-runs-checks-\d{2}-\d{4}$/), + expect.arrayContaining([ + expect.objectContaining({ + number: 123, + merged: true, + repository: 'repo', + organization: 'org', + name: 'Test Check', + conclusion: 'success', + }), + ]), + ); + expect(app.log.info).toHaveBeenCalledWith('All log data indexed successfully.'); + }); + + it('should log an error if bulk indexing fails', async () => { + jest.spyOn(OpensearchClient.prototype, 'bulkIndex').mockRejectedValue(new Error('Indexing failed')); + await githubMergedPullsMonitor(app, context); + expect(app.log.error).toHaveBeenCalledWith('Error indexing log data: Error: Indexing failed'); + }); +}); diff --git a/test/call/github-workflow-runs-monitor.test.ts b/test/call/github-workflow-runs-monitor.test.ts new file mode 100644 index 0000000..5880d1d --- /dev/null +++ b/test/call/github-workflow-runs-monitor.test.ts @@ -0,0 +1,101 @@ +import githubWorkflowRunsMonitor from '../../src/call/github-workflow-runs-monitor'; +import { Probot, Logger } from 'probot'; +import { OpensearchClient } from '../../src/utility/opensearch/opensearch-client'; + +jest.mock('../../src/utility/opensearch/opensearch-client'); + +describe('githubWorkflowRunsMonitor', () => { + let app: Probot; + let context: any; + + beforeEach(() => { + app = new Probot({ appId: 1, secret: 'test', privateKey: 'test' }); + app.log = { + info: jest.fn(), + error: jest.fn(), + } as unknown as Logger; + + context = { + payload: { + workflow_run: { + event: 'push', + id: 123, + name: 'Test Workflow', + head_branch: 'main', + head_sha: 'abcdef123456', + path: '/path/to/workflow', + display_title: 'Test Workflow', + created_at: '2023-09-25T12:00:00Z', + run_started_at: '2023-09-26T12:00:00Z', + updated_at: '2023-09-26T13:00:00Z', + completed_at: '2023-09-26T14:00:00Z', + triggering_actor: { + login: 'test-user', + type: 'User', + }, + url: 'http://example.com', + html_url: 'http://example.com/html', + status: 'completed', + conclusion: 'success', + jobs_url: 'http://example.com/jobs', + }, + repository: { + name: 'repo', + owner: { login: 'org' }, + }, + organization: { + login: 'org', + }, + }, + }; + }); + + it('should skip indexing when the event is not relevant', async () => { + const events = ['pull_request', 'release']; + context.payload.workflow_run.event = 'push'; // Setting an event that is not in the list + + await githubWorkflowRunsMonitor(app, context, { events }); + + expect(app.log.info).toHaveBeenCalledWith('Event not relevant. Not Indexing...'); + }); + + it('should index log data when the event is relevant', async () => { + const events = ['push', 'pull_request']; + + const mockClient = { + index: jest.fn().mockResolvedValue({}), + }; + (OpensearchClient as jest.Mock).mockImplementation(() => { + return { getClient: jest.fn().mockResolvedValue(mockClient) }; + }); + await githubWorkflowRunsMonitor(app, context, { events }); + expect(mockClient.index).toHaveBeenCalledWith({ + index: expect.stringMatching(/^github-ci-workflow-runs-\d{2}-\d{4}$/), + body: expect.objectContaining({ + event: 'push', + repository: 'repo', + organization: 'org', + id: 123, + name: 'Test Workflow', + head_branch: 'main', + head_sha: 'abcdef123456', + triggering_actor_login: 'test-user', + triggering_actor_type: 'User', + }), + }); + expect(app.log.info).toHaveBeenCalledWith('Log data indexed successfully.'); + }); + + it('should log an error if indexing fails', async () => { + const events = ['push', 'pull_request']; + + const mockClient = { + index: jest.fn().mockRejectedValue(new Error('Indexing failed')), + }; + (OpensearchClient as jest.Mock).mockImplementation(() => { + return { getClient: jest.fn().mockResolvedValue(mockClient) }; + }); + await githubWorkflowRunsMonitor(app, context, { events }); + expect(app.log.error).toHaveBeenCalledWith('Error indexing log data: Error: Indexing failed'); + }); +}); diff --git a/test/fixtures/mock-cert.pem b/test/fixtures/mock-cert.pem index f2f271c..746a8eb 100644 --- a/test/fixtures/mock-cert.pem +++ b/test/fixtures/mock-cert.pem @@ -1,3 +1,10 @@ +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + -----BEGIN RSA PRIVATE KEY----- MIIEowIBAAKCAQEAli7V49NdZe+XYC1pLaHM0te8kiDmZBJ1u2HJHN8GdbROB6NO VpC3xK7NxQn6xpvZ9ux20NvcDvGle+DOptZztBH+np6h2jZQ1/kD1yG1eQvVH4th diff --git a/test/index.test.ts b/test/index.test.ts deleted file mode 100644 index fb890f0..0000000 --- a/test/index.test.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* eslint-disable */ -// @ts-nocheck - -// You can import your modules -// import index from '../src/index' - -import nock from 'nock'; -// Requiring our app implementation -import { Probot, ProbotOctokit } from 'probot'; -// Requiring our fixtures -// import payload from "./fixtures/issues.opened.json" with { "type": "json"}; -import fs from 'fs'; -import path from 'path'; -import { fileURLToPath } from 'url'; -import myProbotApp from '../src/index'; - -const issueCreatedBody = { body: 'Thanks for opening this issue!' }; - -const privateKey = fs.readFileSync(path.join(__dirname, 'fixtures/mock-cert.pem'), 'utf-8'); - -const payload = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/issues.opened.json'), 'utf-8')); - -describe('My Probot app', () => { - let probot: any; - - beforeEach(() => { - nock.disableNetConnect(); - probot = new Probot({ - appId: 123, - privateKey, - // disable request throttling and retries for testing - Octokit: ProbotOctokit.defaults({ - retry: { enabled: false }, - throttle: { enabled: false }, - }), - }); - // Load our app into probot - probot.load(myProbotApp); - }); - - test('creates a comment when an issue is opened', async () => { - const mock = nock('https://api.github.com') - // Test that we correctly return a test token - .post('/app/installations/2/access_tokens') - .reply(200, { - token: 'test', - permissions: { - issues: 'write', - }, - }) - - // Test that a comment is posted - .post('/repos/hiimbex/testing-things/issues/1/comments', (body: any) => { - expect(body).toMatchObject(issueCreatedBody); - return true; - }) - .reply(200); - - // Receive a webhook event - await probot.receive({ name: 'issues', payload }); - - expect(mock.pendingMocks()).toStrictEqual([]); - }); - - afterEach(() => { - nock.cleanAll(); - nock.enableNetConnect(); - }); -}); - -// For more information about testing with Jest see: -// https://facebook.github.io/jest/ - -// For more information about using TypeScript in your tests, Jest recommends: -// https://github.com/kulshekhar/ts-jest - -// For more information about testing with Nock see: -// https://github.com/nock/nock diff --git a/test/utility/opensearchclient.test.ts b/test/utility/opensearch/opensearch-client.test.ts similarity index 96% rename from test/utility/opensearchclient.test.ts rename to test/utility/opensearch/opensearch-client.test.ts index 490cd1b..a613245 100644 --- a/test/utility/opensearchclient.test.ts +++ b/test/utility/opensearch/opensearch-client.test.ts @@ -1,4 +1,5 @@ -/** +/* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to @@ -8,7 +9,7 @@ import { STSClient, AssumeRoleCommand } from '@aws-sdk/client-sts'; import { Client as OpenSearchClient } from '@opensearch-project/opensearch'; -import { OpensearchClient } from '../../src/utility/opensearchclient'; // Adjust import path as needed +import { OpensearchClient } from '../../../src/utility/opensearch/opensearch-client'; jest.mock('@aws-sdk/client-sts'); jest.mock('@opensearch-project/opensearch');