Skip to content

Commit

Permalink
Updated tests for ros_gz
Browse files Browse the repository at this point in the history
Signed-off-by: Saurabh Kamat <kamatsaurabh01@gmail.com>
  • Loading branch information
sauk2 committed Aug 25, 2024
1 parent df0b880 commit 5584857
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,4 @@ jobs:
uses: ./
with:
required-gazebo-distributions: 'harmonic'
install-ros-gz: 'true'
install-ros-gz: 'jazzy iron'
26 changes: 25 additions & 1 deletion __test__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("workflow test with a invalid distro input", () => {
beforeAll(() => {
jest.spyOn(exec, "exec").mockImplementation(jest.fn());
jest.spyOn(core, "getInput").mockReturnValue("dome");
jest.spyOn(utils, "checkForRosGz").mockReturnValue([]);
});

afterAll(() => {
Expand All @@ -55,6 +56,7 @@ describe("workflow test with a valid distro input", () => {
beforeAll(() => {
jest.spyOn(exec, "exec").mockImplementation(jest.fn());
jest.spyOn(core, "getInput").mockReturnValue("harmonic");
jest.spyOn(utils, "checkForRosGz").mockReturnValue([]);
jest
.spyOn(utils, "determineDistribCodename")
.mockReturnValue(Promise.resolve("jammy"));
Expand All @@ -77,7 +79,7 @@ describe("workflow test with a valid distro input", () => {
});
});

describe("validate distribution test", () => {
describe("validate Gazebo distribution test", () => {
it("test valid distro", async () => {
await expect(utils.validateDistro(["citadel"])).toBe(true);
await expect(utils.validateDistro(["fortress"])).toBe(true);
Expand All @@ -98,10 +100,31 @@ describe("validate distribution test", () => {
});
});

describe("validate ROS 2 distribution test", () => {
it("test valid distro", async () => {
await expect(utils.validateRosDistro(["humble"])).toBe(true);
await expect(utils.validateRosDistro(["iron"])).toBe(true);
await expect(utils.validateRosDistro(["jazzy"])).toBe(true);
await expect(utils.validateRosDistro(["rolling"])).toBe(true);
await expect(utils.validateRosDistro(["humble", "jazzy"])).toBe(true);
});
it("test invalid distro", async () => {
await expect(utils.validateRosDistro(["noetic"])).toBe(false);
await expect(utils.validateRosDistro(["foxy"])).toBe(false);
await expect(utils.validateRosDistro(["galactic"])).toBe(false);
await expect(utils.validateRosDistro(["doesNotExist"])).toBe(false);
await expect(utils.validateRosDistro(["noetic", "humble"])).toBe(false);
await expect(utils.validateRosDistro(["foxy", "galactic", "jazzy"])).toBe(
false,
);
});
});

describe("workflow test with incompatible Ubuntu combination", () => {
beforeAll(() => {
jest.spyOn(exec, "exec").mockImplementation(jest.fn());
jest.spyOn(core, "getInput").mockReturnValue("harmonic");
jest.spyOn(utils, "checkForRosGz").mockReturnValue([]);
jest
.spyOn(utils, "determineDistribCodename")
.mockReturnValue(Promise.resolve("focal"));
Expand All @@ -128,6 +151,7 @@ describe("check for unstable repositories input", () => {
.spyOn(utils, "checkForUnstableAptRepos")
.mockReturnValueOnce(["prerelease", "nightly"]);
jest.spyOn(core, "getInput").mockReturnValue("harmonic");
jest.spyOn(utils, "checkForRosGz").mockReturnValue([]);
jest
.spyOn(utils, "determineDistribCodename")
.mockReturnValue(Promise.resolve("jammy"));
Expand Down

0 comments on commit 5584857

Please sign in to comment.