test: add unit tests for src/main.ts#36
Conversation
|
Thanks @Neev213 for the comprehensive test suite (539 lines)! The CI build is failing because of a vitest mocking issue: the vi.mock factory functions reference top-level variables, which vitest does not support since vi.mock factories are hoisted above all imports. To fix: use vi.hoisted to define mocks that can be referenced inside vi.mock factories: const mockCore = vi.hoisted(() => ({ getInput: vi.fn(), ... })); Once the build passes, this is the most comprehensive test suite for src/main.ts and we would love to merge it! |
|
Hey @Neev213! 👋 Thanks for picking up #28. Heads-up that #66 from @ifauzeee is working on the same issue with a more complete change set (modifies |
Summary
Adds
src/main.test.tswith comprehensive unit tests for the main module functions.Changes
src/main.test.tswith vitest tests covering:parseVersionFile()vprefix when followed by a digit (e.g.,v0.2.0→0.2.0)vwhen not followed by a digit (e.g.,version-1.0.0stays unchanged)v1.2.3-rc1)strToBoolean()true,yes,1, uppercase variantsfalse,no,0,'',undefined,nullgetVersion()v versionstdout output0.0.0when stdout is emptyresolveVersionInput()versioninputversion-filewhen specifiedvprefix from version-file contentsCache logic (via
run())v-{version}-{platform}-{arch}formatcacheinput isfalseor version is not providedError handling
core.setFailed()called whenrun()throwsarchitectureis set butversionis missingRelated issue
Closes #28