Skip to content

Commit b32b3d2

Browse files
committed
fix(MongoBinaryDownloadUrl): add "cachyos" as arch-like
Also adds tests for cachyos due to weird output in issue. re #947
1 parent 99db5a5 commit b32b3d2

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
237237
} else if (regexHelper(/alpine/i, os)) {
238238
console.warn('There is no official build of MongoDB for Alpine!');
239239
// Match "arch", "archlinux", "manjaro", "manjarolinux", "arco", "arcolinux"
240-
} else if (regexHelper(/(arch|manjaro|arco)(?:linux)?$/i, os)) {
240+
} else if (regexHelper(/(arch|manjaro|arco|cachyos)(?:linux)?$/i, os)) {
241241
console.warn(
242242
`There is no official build of MongoDB for ArchLinux (${os.dist}). Falling back to Ubuntu 22.04 release.`
243243
);

packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,26 @@ describe('MongoBinaryDownloadUrl', () => {
864864
);
865865
expect(console.warn).toHaveBeenCalledTimes(1);
866866
});
867+
868+
it('cachyos (x86_64) & 8.0.7 (using ubuntu2404)', async () => {
869+
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
870+
871+
const du = new MongoBinaryDownloadUrl({
872+
platform: 'linux',
873+
arch: 'x64',
874+
version: '8.0.7',
875+
os: {
876+
os: 'linux',
877+
dist: 'cachyos',
878+
release: '',
879+
id_like: [],
880+
},
881+
});
882+
expect(await du.getDownloadUrl()).toBe(
883+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-8.0.7.tgz'
884+
);
885+
expect(console.warn).toHaveBeenCalledTimes(1);
886+
});
867887
});
868888

869889
describe('for gentoo', () => {

packages/mongodb-memory-server-core/src/util/getos/__tests__/getos.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,29 @@ HOME_URL="https://amazonlinux.com/"`;
144144
);
145145
});
146146
});
147+
148+
describe('extra os tests', () => {
149+
it('should parse cachyos', () => {
150+
// output taken from https://github.com/typegoose/mongodb-memory-server/issues/947
151+
const example = `NAME="CachyOS Linux"
152+
PRETTY_NAME="CachyOS"
153+
ID=cachyos
154+
BUILD_ID=rolling
155+
ANSI_COLOR="38;2;23;147;209"
156+
HOME_URL="https://cachyos.org/"
157+
DOCUMENTATION_URL="https://wiki.cachyos.org/"
158+
SUPPORT_URL="https://discuss.cachyos.org/"
159+
BUG_REPORT_URL="https://github.com/cachyos"
160+
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
161+
LOGO=cachyos`;
162+
163+
expect(getos.parseOS(example)).toEqual<getos.LinuxOS>({
164+
os: 'linux',
165+
dist: 'cachyos',
166+
release: '',
167+
codename: undefined,
168+
id_like: undefined,
169+
});
170+
});
171+
});
147172
});

0 commit comments

Comments
 (0)