Skip to content

Commit

Permalink
Rename and refactor Docker-related modules and test imports
Browse files Browse the repository at this point in the history
Refactored module structures to replace "docker" with "containers" in relevant paths and updated associated unit tests accordingly. Renamed `performAction` to `performDockerAction` for clarity and consistency in Docker action handling. These changes improve module organization and enhance code readability.
  • Loading branch information
SquirrelDevelopper committed Dec 23, 2024
1 parent 2cfa8a9 commit 9f1627b
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ vi.mock('../../../../services/ContainerUseCases', async (importOriginal) => {
return {
...(await importOriginal<typeof import('../../../../services/ContainerUseCases')>()),
default: {
performAction: (container: Container, action: SsmContainer.Actions) => {
performDockerAction: (container: Container, action: SsmContainer.Actions) => {
if (action === SsmContainer.Actions.PAUSE) {
return;
}
Expand All @@ -60,7 +60,7 @@ describe('DockerActionComponent', () => {
beforeEach(async () => {
vi.resetAllMocks();
vi.spyOn(ContainerRepo, 'findContainerById');
vi.spyOn(ContainerUseCases, 'performAction');
vi.spyOn(ContainerUseCases, 'performDockerAction');
});
afterEach(() => {
vi.restoreAllMocks();
Expand All @@ -78,8 +78,8 @@ describe('DockerActionComponent', () => {
await dockerActionComponent.executeAction();

expect(ContainerRepo.findContainerById).toHaveBeenCalledWith('container1');
expect(ContainerUseCases.performAction).toHaveBeenCalledTimes(2); // Assuming you have two containers
expect(ContainerUseCases.performAction).toHaveBeenCalledWith(fakeContainer, dockerAction);
expect(ContainerUseCases.performDockerAction).toHaveBeenCalledTimes(2); // Assuming you have two containers
expect(ContainerUseCases.performDockerAction).toHaveBeenCalledWith(fakeContainer, dockerAction);
});

test('executeAction handles no containers provided', async () => {
Expand All @@ -92,7 +92,7 @@ describe('DockerActionComponent', () => {

// No action should be performed when no containers are provided
await dockerActionComponent.executeAction();
expect(ContainerUseCases.performAction).not.toHaveBeenCalled();
expect(ContainerUseCases.performDockerAction).not.toHaveBeenCalled();
});

test('executeAction handles failed container retrieval', async () => {
Expand All @@ -105,7 +105,7 @@ describe('DockerActionComponent', () => {

// An error should be thrown if the container can't be retrieved
expect(dockerActionComponent.executeAction()).resolves.toBeUndefined();
expect(ContainerUseCases.performAction).not.toHaveBeenCalled();
expect(ContainerUseCases.performDockerAction).not.toHaveBeenCalled();
});

test('executeAction handles failed performAction execution', async () => {
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Acr.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest';
import Acr from '../../../../modules/docker/registries/providers/acr/Acr';
import Acr from '../../../../modules/containers/registries/providers/acr/Acr';

describe('testing Acr Registry', () => {
const acr = new Acr();
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Custom.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest';
import Custom from '../../../../modules/docker/registries/providers/custom/Custom';
import Custom from '../../../../modules/containers/registries/providers/custom/Custom';

describe('testing Custom Registry', () => {
const custom = new Custom();
Expand Down
10 changes: 5 additions & 5 deletions server/src/tests/unit-tests/modules/docker/Docker.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { randomUUID } from 'node:crypto';
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import Container from '../../../../data/database/model/Container';
import Acr from '../../../../modules/docker/registries/providers/acr/Acr';
import Ecr from '../../../../modules/docker/registries/providers/ecr/Ecr';
import Gcr from '../../../../modules/docker/registries/providers/gcr/Gcr';
import Hub from '../../../../modules/docker/registries/providers/hub/Hub';
import Docker from '../../../../modules/docker/watchers/providers/docker/Docker';
import Acr from '../../../../modules/containers/registries/providers/acr/Acr';
import Ecr from '../../../../modules/containers/registries/providers/ecr/Ecr';
import Gcr from '../../../../modules/containers/registries/providers/gcr/Gcr';
import Hub from '../../../../modules/containers/registries/providers/hub/Hub';
import Docker from '../../../../modules/containers/watchers/providers/docker/Docker';
import sampleSemver from './samples/semver.json';

let docker: Docker;
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Ecr.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, test, vi } from 'vitest';
import Ecr from '../../../../modules/docker/registries/providers/ecr/Ecr';
import Ecr from '../../../../modules/containers/registries/providers/ecr/Ecr';

describe('testing ECR Registry', () => {
const ecr = new Ecr();
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Forjejo.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest';
import Forgejo from '../../../../modules/docker/registries/providers/forgejo/Forgejo';
import Forgejo from '../../../../modules/containers/registries/providers/forgejo/Forgejo';

describe('testing Forjejo Registry', () => {
const forgejo = new Forgejo();
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Gcr.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import Gcr from '../../../../modules/docker/registries/providers/gcr/Gcr';
import Gcr from '../../../../modules/containers/registries/providers/gcr/Gcr';

describe('testing GCR Registry', () => {
const gcr = new Gcr();
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Ghcr.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import Ghcr from '../../../../modules/docker/registries/providers/ghcr/Ghcr';
import Ghcr from '../../../../modules/containers/registries/providers/ghcr/Ghcr';

describe('testing GHCR Registry', () => {
const ghcr = new Ghcr();
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Gitea.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest';
import Gitea from '../../../../modules/docker/registries/providers/gitea/Gitea';
import Gitea from '../../../../modules/containers/registries/providers/gitea/Gitea';

describe('testing Gitea Registry', () => {
const gitea = new Gitea();
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Gitlab.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import Gitlab from '../../../../modules/docker/registries/providers/gitlab/Gitlab';
import Gitlab from '../../../../modules/containers/registries/providers/gitlab/Gitlab';

describe('testing Gitlab Registry', () => {
const gitlab = new Gitlab();
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Hub.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import Hub from '../../../../modules/docker/registries/providers/hub/Hub';
import Hub from '../../../../modules/containers/registries/providers/hub/Hub';

describe('testing Hub Registry', () => {
const hub = new Hub();
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Lscr.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest';
import Lscr from '../../../../modules/docker/registries/providers/lscr/Lscr';
import Lscr from '../../../../modules/containers/registries/providers/lscr/Lscr';

describe('testing Lscr Registry', () => {
const lscr = new Lscr();
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/Quay.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import Quay from '../../../../modules/docker/registries/providers/quay/Quay';
import Quay from '../../../../modules/containers/registries/providers/quay/Quay';

describe('testing Quay Registry', () => {
const quay = new Quay();
Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/unit-tests/modules/docker/tag.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest';
import tag from '../../../../modules/docker/utils/tag';
import tag from '../../../../modules/containers/utils/tag';

describe('testing tag', () => {
const parseTestCases = [
Expand Down

0 comments on commit 9f1627b

Please sign in to comment.